diff piecrust/commands/builtin/baking.py @ 854:08e02c2a2a1a

core: Keep refactoring, this time to prepare for generator sources. - Make a few APIs simpler. - Content pipelines create their own jobs, so that generator sources can keep aborting in `getContents`, but rely on their pipeline to generate pages for baking.
author Ludovic Chabant <ludovic@chabant.com>
date Sun, 04 Jun 2017 23:34:28 -0700
parents f070a4fc033c
children 8d25f76fce98
line wrap: on
line diff
--- a/piecrust/commands/builtin/baking.py	Sun May 21 00:06:59 2017 -0700
+++ b/piecrust/commands/builtin/baking.py	Sun Jun 04 23:34:28 2017 -0700
@@ -1,7 +1,9 @@
+import os.path
 import time
-import os.path
+import pprint
 import logging
 import fnmatch
+import textwrap
 import datetime
 from colorama import Fore
 from piecrust.commands.base import ChefCommand
@@ -28,7 +30,7 @@
         parser.add_argument(
             '-p', '--pipelines',
             help="The pipelines to run.",
-            nargs='*')
+            action='append')
         parser.add_argument(
             '-w', '--workers',
             help="The number of worker processes to spawn.",
@@ -91,6 +93,10 @@
         elif ctx.args.assets_only:
             allowed_pipelines = ['asset']
         elif ctx.args.pipelines:
+            if allowed_pipelines:
+                raise Exception(
+                    "Can't specify `--html-only` or `--assets-only` with "
+                    "`--pipelines`.")
             allowed_pipelines = ctx.args.pipelines
 
         baker = Baker(
@@ -200,14 +206,14 @@
             logger.info("Record: %s" % rec.name)
             logger.info("Status: %s" % ('SUCCESS' if rec.success
                                         else 'FAILURE'))
-            for e in rec.entries:
+            for e in rec.getEntries():
                 if ctx.args.fails and e.success:
                     continue
                 if in_pattern and not fnmatch.fnmatch(e.item_spec, in_pattern):
                     continue
                 if out_pattern and not any(
                         [fnmatch.fnmatch(op, out_pattern)
-                         for op in e.out_paths]):
+                         for op in e.getAllOutputPaths()]):
                     continue
                 _print_record_entry(e)
 
@@ -260,17 +266,24 @@
 def _print_record_entry(e):
     logger.info(" - %s" % e.item_spec)
     logger.info("   Outputs:")
-    if e.out_paths:
-        for op in e.out_paths:
+    out_paths = list(e.getAllOutputPaths())
+    if out_paths:
+        for op in out_paths:
             logger.info("    - %s" % op)
     else:
         logger.info("      <none>")
 
     e_desc = e.describe()
-    for k in sorted(e_desc.keys()):
-        logger.info("   %s: %s" % (k, e_desc[k]))
+    for k, v in e_desc.items():
+        if isinstance(v, dict):
+            text = pprint.pformat(v, indent=2)
+            logger.info("   %s:" % k)
+            logger.info(textwrap.indent(text, '     '))
+        else:
+            logger.info("   %s: %s" % (k, v))
 
-    if e.errors:
+    errors = list(e.getAllErrors())
+    if errors:
         logger.error("   Errors:")
-        for err in e.errors:
+        for err in errors:
             logger.error("    - %s" % err)