Mercurial > piecrust2
comparison piecrust/pipelines/_procrecords.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 | 448710d84121 |
comparison
equal
deleted
inserted
replaced
853:f070a4fc033c | 854:08e02c2a2a1a |
---|---|
1 from piecrust.pipelines.records import RecordEntry | 1 from piecrust.pipelines.records import ( |
2 RecordEntry, get_flag_descriptions) | |
2 | 3 |
3 | 4 |
4 class AssetPipelineRecordEntry(RecordEntry): | 5 class AssetPipelineRecordEntry(RecordEntry): |
5 FLAG_NONE = 0 | 6 FLAG_NONE = 0 |
6 FLAG_PREPARED = 2**0 | 7 FLAG_PREPARED = 2**0 |
10 | 11 |
11 def __init__(self): | 12 def __init__(self): |
12 super().__init__() | 13 super().__init__() |
13 self.flags = self.FLAG_NONE | 14 self.flags = self.FLAG_NONE |
14 self.proc_tree = None | 15 self.proc_tree = None |
16 self.out_paths = [] | |
15 | 17 |
16 @property | 18 @property |
17 def was_prepared(self): | 19 def was_prepared(self): |
18 return bool(self.flags & self.FLAG_PREPARED) | 20 return bool(self.flags & self.FLAG_PREPARED) |
19 | 21 |
31 def was_collapsed_from_last_run(self): | 33 def was_collapsed_from_last_run(self): |
32 return self.flags & self.FLAG_COLLAPSED_FROM_LAST_RUN | 34 return self.flags & self.FLAG_COLLAPSED_FROM_LAST_RUN |
33 | 35 |
34 def describe(self): | 36 def describe(self): |
35 d = super().describe() | 37 d = super().describe() |
36 d['Flags'] = _get_flag_descriptions(self.flags) | 38 d['Flags'] = get_flag_descriptions(self.flags, flag_descriptions) |
37 d['Processing Tree'] = _format_proc_tree(self.proc_tree, 20 * ' ') | 39 d['Processing Tree'] = _format_proc_tree(self.proc_tree, 20 * ' ') |
40 d['Outputs'] = list(self.out_paths) | |
38 return d | 41 return d |
39 | 42 |
40 | 43 |
41 flag_descriptions = { | 44 flag_descriptions = { |
42 AssetPipelineRecordEntry.FLAG_PREPARED: 'prepared', | 45 AssetPipelineRecordEntry.FLAG_PREPARED: 'prepared', |
43 AssetPipelineRecordEntry.FLAG_PROCESSED: 'processed', | 46 AssetPipelineRecordEntry.FLAG_PROCESSED: 'processed', |
44 AssetPipelineRecordEntry.FLAG_BYPASSED_STRUCTURED_PROCESSING: 'external', | 47 AssetPipelineRecordEntry.FLAG_BYPASSED_STRUCTURED_PROCESSING: 'external', |
45 AssetPipelineRecordEntry.FLAG_COLLAPSED_FROM_LAST_RUN: 'from last run'} | 48 AssetPipelineRecordEntry.FLAG_COLLAPSED_FROM_LAST_RUN: 'from last run'} |
46 | 49 |
47 | 50 |
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): | 51 def _format_proc_tree(tree, margin='', level=0): |
59 name, children = tree | 52 name, children = tree |
60 res = '%s%s+ %s\n' % (margin if level > 0 else '', level * ' ', name) | 53 res = '%s%s+ %s\n' % (margin if level > 0 else '', level * ' ', name) |
61 if children: | 54 if children: |
62 for c in children: | 55 for c in children: |