diff piecrust/pipelines/_pagerecords.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 4850f8c21b6e
children 504ddb370df8
line wrap: on
line diff
--- a/piecrust/pipelines/_pagerecords.py	Sun May 21 00:06:59 2017 -0700
+++ b/piecrust/pipelines/_pagerecords.py	Sun Jun 04 23:34:28 2017 -0700
@@ -1,5 +1,5 @@
 import copy
-from piecrust.pipelines.records import RecordEntry
+from piecrust.pipelines.records import RecordEntry, get_flag_descriptions
 
 
 class SubPagePipelineRecordEntry:
@@ -44,6 +44,7 @@
     FLAG_NEW = 2**0
     FLAG_SOURCE_MODIFIED = 2**1
     FLAG_OVERRIDEN = 2**2
+    FLAG_COLLAPSED_FROM_LAST_RUN = 2**3
 
     def __init__(self):
         super().__init__()
@@ -52,6 +53,10 @@
         self.subs = []
 
     @property
+    def was_touched(self):
+        return (self.flags & self.FLAG_SOURCE_MODIFIED) != 0
+
+    @property
     def was_overriden(self):
         return (self.flags & self.FLAG_OVERRIDEN) != 0
 
@@ -67,16 +72,6 @@
         return False
 
     @property
-    def all_assets(self):
-        for sub in self.subs:
-            yield from sub.assets
-
-    @property
-    def all_out_paths(self):
-        for sub in self.subs:
-            yield sub.out_path
-
-    @property
     def has_any_error(self):
         if len(self.errors) > 0:
             return True
@@ -101,3 +96,36 @@
                     res |= pinfo.used_source_names
         return res
 
+    def getAllOutputPaths(self):
+        for o in self.subs:
+            yield o.out_path
+
+    def describe(self):
+        d = super().describe()
+        d['Flags'] = get_flag_descriptions(self.flags, flag_descriptions)
+        for i, sub in enumerate(self.subs):
+            d['Sub%02d' % i] = {
+                'URI': sub.out_uri,
+                'Path': sub.out_path,
+                'Flags': get_flag_descriptions(
+                    sub.flags, sub_flag_descriptions)
+            }
+        return d
+
+
+flag_descriptions = {
+    PagePipelineRecordEntry.FLAG_NEW: 'new',
+    PagePipelineRecordEntry.FLAG_SOURCE_MODIFIED: 'touched',
+    PagePipelineRecordEntry.FLAG_OVERRIDEN: 'overriden',
+    PagePipelineRecordEntry.FLAG_COLLAPSED_FROM_LAST_RUN: 'from last run'}
+
+
+sub_flag_descriptions = {
+    SubPagePipelineRecordEntry.FLAG_BAKED: 'baked',
+    SubPagePipelineRecordEntry.FLAG_FORCED_BY_SOURCE: 'forced by source',
+    SubPagePipelineRecordEntry.FLAG_FORCED_BY_NO_PREVIOUS: 'forced b/c new',
+    SubPagePipelineRecordEntry.FLAG_FORCED_BY_PREVIOUS_ERRORS:
+    'forced by errors',
+    SubPagePipelineRecordEntry.FLAG_FORMATTING_INVALIDATED:
+    'formatting invalidated'
+}