1. dan mackinlay
  2. possumpalace_kit

Source

possumpalace_kit / pavement.py

import os.path
import sys
here = os.path.abspath('.')
sys.path.append(os.path.join(here, 'content'))
sys.path.append(os.path.join(here, '_ext'))
sys.path.append(os.path.join(here, '_lib'))
sys.path.append(here)

from paver.easy import BuildFailure, Bunch, PavementError, call_pavement, call_task, cmdopts, consume_args, debug, dry, environment, error, info, needs, no_auto, options, path, paver, pushd, sh, subprocess, sys, task, tasks
import paver.doctools
from paver.path25 import path
from paver.setuputils import setup
# from sphinxcontrib import paverutils
# try:
import conf
# except ImportError:
#     conf = None

options(
    deploy=Bunch(
        htmldir=path('content/_build/html/'),
        host=getattr(conf, 'host', ''),
        hostpath=getattr(conf, 'hostpath', ''),
        username=getattr(conf, 'username', ''),
        siteurl=getattr(conf, 'siteurl', '')
    ),
    update_sphinx_contrib=Bunch(
        sphinx_contrib_path=path("_lib/sphinx_contrib"),
        sphinx_ext_path=path("_ext/sphinxcontrib"),
        sphinx_contrib_repos_url=("http://bitbucket.org/"
          "birkenfeld/sphinx-contrib/")
    ),
    sphinx=Bunch(
        docroot='content',
        sourcedir='.',
        builder='html',
    ),
    html=Bunch(
        builddir='_build',
        confdir='.',
    ),
)

setup(
    name="PossumPalace Blog",
    packages=['possumpalace_content'],
    version="1.0",
    url="http://blog.possumpalace.org/",
    author="Dan MacKinlay",
    author_email="possumpalace@email.possumpalace.org"
)

@task
def update_sphinx_contrib():
    if options.sphinx_contrib_path.exists() and options.sphinx_contrib_path.isdir() and \
      (options.sphinx_contrib_path/".hg").exists():
        with pushd(options.sphinx_contrib_path) as old_dir:
            sh("hg pull")
            sh("hg update")
    else:
        options.sphinx_contrib_path.makedirs()
        with pushd(options.sphinx_contrib_path.parent) as old_dir:
            sh("""
            hg clone %s %s
            """ % (options.sphinx_contrib_repos_url, options.sphinx_contrib_path.basename()))
            
    options.sphinx_ext_path.makedirs()
    for lib_path in options.sphinx_contrib_path.dirs():
        lib_path = path(lib_path)
        ext_name = lib_path.basename()
        if ext_name.startswith('_') or ext_name.startswith('.'): continue
        lib_namespaced_path = lib_path/'sphinxcontrib'
        ext_path = options.sphinx_ext_path/ext_name
        ext_path.unlink()
        ext_path.remove()
        if not ext_path.exists():
            ext_path.parent.relpathto(lib_namespaced_path).symlink(
                ext_path
            )
    path(options.sphinx_ext_path/'__init__.py').touch()

@task
def compile_coffeescript():
    with pushd("content") as old_dir:
        sh('find . -name "*.coffee" -print0 |xargs -0 coffee -c')
    
@task
@needs(['compile_coffeescript'])
def deploy(options):
    """Deploy the HTML to the server."""
    sh("rsync -avz --delete %s %s@%s:%s/" % (options.htmldir,
            options.username, options.host, options.hostpath))
    sh("open %s" % options.siteurl)

@task
def clear_build():
    """test new template changes or what have you with a clean slate"""
    sh("rm -rf content/_build")
    
@task
@needs(['clear_build', 'html'])
def rebuild_html():
    """i do this so often when themeing"""
    pass