view piecrust/commands/base.py @ 1:aaa8fb7c8918

Re-arranged modules to reduce dependencies to builtin stuff. Added `init` command.
author Ludovic Chabant <ludovic@chabant.com>
date Sun, 22 Dec 2013 08:00:24 -0800
parents a212a3f2e3ee
children f485ba500df3
line wrap: on
line source

import logging
from piecrust.pathutil import SiteNotFoundError


logger = logging.getLogger(__name__)


class CommandContext(object):
    def __init__(self, app, args):
        self.app = app
        self.args = args


class ChefCommand(object):
    def __init__(self):
        self.name = '__unknown__'
        self.description = '__unknown__'
        self.requires_website = True

    def setupParser(self, parser):
        raise NotImplementedError()

    def run(self, ctx):
        raise NotImplementedError()

    def _runFromChef(self, app, res):
        if app.root is None and self.requires_website:
            raise SiteNotFoundError()
        self.run(CommandContext(app, res))