diff piecrust/commands/base.py @ 852:4850f8c21b6e

core: Start of the big refactor for PieCrust 3.0. * Everything is a `ContentSource`, including assets directories. * Most content sources are subclasses of the base file-system source. * A source is processed by a "pipeline", and there are 2 built-in pipelines, one for assets and one for pages. The asset pipeline is vaguely functional, but the page pipeline is completely broken right now. * Rewrite the baking process as just running appropriate pipelines on each content item. This should allow for better parallelization.
author Ludovic Chabant <ludovic@chabant.com>
date Wed, 17 May 2017 00:11:48 -0700
parents 3ceeca7bb71c
children 07c23be08029
line wrap: on
line diff
--- a/piecrust/commands/base.py	Sat Apr 29 21:42:22 2017 -0700
+++ b/piecrust/commands/base.py	Wed May 17 00:11:48 2017 -0700
@@ -8,12 +8,11 @@
 
 
 class CommandContext(object):
-    def __init__(self, app, parser, args):
+    def __init__(self, appfactory, app, parser, args):
+        self.appfactory = appfactory
         self.app = app
         self.parser = parser
         self.args = args
-        self.config_variant = None
-        self.config_values = None
 
 
 class ChefCommand(object):
@@ -27,8 +26,9 @@
         raise NotImplementedError()
 
     def run(self, ctx):
-        raise NotImplementedError("Command '%s' doesn't implement the `run` "
-                "method." % type(self))
+        raise NotImplementedError(
+            "Command '%s' doesn't implement the `run` "
+            "method." % type(self))
 
     def checkedRun(self, ctx):
         if ctx.app.root_dir is None and self.requires_website:
@@ -83,8 +83,9 @@
         return [(n, d) for (n, d, e) in self._topic_providers]
 
     def setupParser(self, parser, app):
-        parser.add_argument('topic', nargs='?',
-                help="The command name or topic on which to get help.")
+        parser.add_argument(
+            'topic', nargs='?',
+            help="The command name or topic on which to get help.")
 
         extensions = self.getExtensions(app)
         for ext in extensions:
@@ -106,8 +107,8 @@
         for c in ctx.app.plugin_loader.getCommands():
             if c.name == topic:
                 fake = argparse.ArgumentParser(
-                        prog='%s %s' % (ctx.parser.prog, c.name),
-                        description=c.description)
+                    prog='%s %s' % (ctx.parser.prog, c.name),
+                    description=c.description)
                 c.setupParser(fake, ctx.app)
                 fake.print_help()
                 return 0