comparison piecrust/pipelines/_procrecords.py @ 853:f070a4fc033c

core: Continue PieCrust3 refactor, simplify pages. The asset pipeline is still the only function pipeline at this point. * No more `QualifiedPage`, and several other pieces of code deleted. * Data providers are simpler and more focused. For instance, the page iterator doesn't try to support other types of items. * Route parameters are proper known source metadata to remove the confusion between the two. * Make the baker and pipeline more correctly manage records and record histories. * Add support for record collapsing and deleting stale outputs in the asset pipeline.
author Ludovic Chabant <ludovic@chabant.com>
date Sun, 21 May 2017 00:06:59 -0700
parents 4850f8c21b6e
children 08e02c2a2a1a
comparison
equal deleted inserted replaced
852:4850f8c21b6e 853:f070a4fc033c
8 FLAG_BYPASSED_STRUCTURED_PROCESSING = 2**3 8 FLAG_BYPASSED_STRUCTURED_PROCESSING = 2**3
9 FLAG_COLLAPSED_FROM_LAST_RUN = 2**4 9 FLAG_COLLAPSED_FROM_LAST_RUN = 2**4
10 10
11 def __init__(self): 11 def __init__(self):
12 super().__init__() 12 super().__init__()
13 self.out_paths = []
14 self.flags = self.FLAG_NONE 13 self.flags = self.FLAG_NONE
15 self.proc_tree = None 14 self.proc_tree = None
16 15
17 @property 16 @property
18 def was_prepared(self): 17 def was_prepared(self):
30 29
31 @property 30 @property
32 def was_collapsed_from_last_run(self): 31 def was_collapsed_from_last_run(self):
33 return self.flags & self.FLAG_COLLAPSED_FROM_LAST_RUN 32 return self.flags & self.FLAG_COLLAPSED_FROM_LAST_RUN
34 33
34 def describe(self):
35 d = super().describe()
36 d['Flags'] = _get_flag_descriptions(self.flags)
37 d['Processing Tree'] = _format_proc_tree(self.proc_tree, 20 * ' ')
38 return d
35 39
40
41 flag_descriptions = {
42 AssetPipelineRecordEntry.FLAG_PREPARED: 'prepared',
43 AssetPipelineRecordEntry.FLAG_PROCESSED: 'processed',
44 AssetPipelineRecordEntry.FLAG_BYPASSED_STRUCTURED_PROCESSING: 'external',
45 AssetPipelineRecordEntry.FLAG_COLLAPSED_FROM_LAST_RUN: 'from last run'}
46
47
48 def _get_flag_descriptions(flags):
49 res = []
50 for k, v in flag_descriptions.items():
51 if flags & k:
52 res.append(v)
53 if res:
54 return ', '.join(res)
55 return 'none'
56
57
58 def _format_proc_tree(tree, margin='', level=0):
59 name, children = tree
60 res = '%s%s+ %s\n' % (margin if level > 0 else '', level * ' ', name)
61 if children:
62 for c in children:
63 res += _format_proc_tree(c, margin, level + 1)
64 return res
65