Mercurial > piecrust2
diff 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 |
line wrap: on
line diff
--- a/piecrust/pipelines/_procrecords.py Wed May 17 00:11:48 2017 -0700 +++ b/piecrust/pipelines/_procrecords.py Sun May 21 00:06:59 2017 -0700 @@ -10,7 +10,6 @@ def __init__(self): super().__init__() - self.out_paths = [] self.flags = self.FLAG_NONE self.proc_tree = None @@ -32,4 +31,35 @@ def was_collapsed_from_last_run(self): return self.flags & self.FLAG_COLLAPSED_FROM_LAST_RUN + def describe(self): + d = super().describe() + d['Flags'] = _get_flag_descriptions(self.flags) + d['Processing Tree'] = _format_proc_tree(self.proc_tree, 20 * ' ') + return d + +flag_descriptions = { + AssetPipelineRecordEntry.FLAG_PREPARED: 'prepared', + AssetPipelineRecordEntry.FLAG_PROCESSED: 'processed', + AssetPipelineRecordEntry.FLAG_BYPASSED_STRUCTURED_PROCESSING: 'external', + AssetPipelineRecordEntry.FLAG_COLLAPSED_FROM_LAST_RUN: 'from last run'} + + +def _get_flag_descriptions(flags): + res = [] + for k, v in flag_descriptions.items(): + if flags & k: + res.append(v) + if res: + return ', '.join(res) + return 'none' + + +def _format_proc_tree(tree, margin='', level=0): + name, children = tree + res = '%s%s+ %s\n' % (margin if level > 0 else '', level * ' ', name) + if children: + for c in children: + res += _format_proc_tree(c, margin, level + 1) + return res +