Mercurial > piecrust2
comparison piecrust/configuration.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 | 7e51d14097cb |
comparison
equal
deleted
inserted
replaced
| 852:4850f8c21b6e | 853:f070a4fc033c |
|---|---|
| 13 logger = logging.getLogger(__name__) | 13 logger = logging.getLogger(__name__) |
| 14 | 14 |
| 15 default_allowed_types = (dict, list, tuple, float, int, bool, str) | 15 default_allowed_types = (dict, list, tuple, float, int, bool, str) |
| 16 | 16 |
| 17 | 17 |
| 18 MERGE_NEW_VALUES = 0 | |
| 19 MERGE_OVERWRITE_VALUES = 1 | |
| 20 MERGE_PREPEND_LISTS = 2 | |
| 21 MERGE_APPEND_LISTS = 4 | |
| 22 MERGE_ALL = MERGE_OVERWRITE_VALUES | MERGE_PREPEND_LISTS | |
| 23 | |
| 24 | |
| 18 class ConfigurationError(Exception): | 25 class ConfigurationError(Exception): |
| 19 pass | 26 pass |
| 20 | 27 |
| 21 | 28 |
| 22 class Configuration(collections.abc.MutableMapping): | 29 class Configuration(collections.abc.MutableMapping): |
| 62 | 69 |
| 63 def getAll(self): | 70 def getAll(self): |
| 64 self._ensureLoaded() | 71 self._ensureLoaded() |
| 65 return self._values | 72 return self._values |
| 66 | 73 |
| 67 def merge(self, other): | 74 def merge(self, other, mode=MERGE_ALL): |
| 68 self._ensureLoaded() | 75 self._ensureLoaded() |
| 69 | 76 |
| 70 if isinstance(other, dict): | 77 if isinstance(other, dict): |
| 71 other_values = other | 78 other_values = other |
| 72 elif isinstance(other, Configuration): | 79 elif isinstance(other, Configuration): |
| 158 cur[b] = value | 165 cur[b] = value |
| 159 else: | 166 else: |
| 160 if b not in cur: | 167 if b not in cur: |
| 161 cur[b] = {} | 168 cur[b] = {} |
| 162 cur = cur[b] | 169 cur = cur[b] |
| 163 | |
| 164 | |
| 165 MERGE_NEW_VALUES = 0 | |
| 166 MERGE_OVERWRITE_VALUES = 1 | |
| 167 MERGE_PREPEND_LISTS = 2 | |
| 168 MERGE_APPEND_LISTS = 4 | |
| 169 MERGE_ALL = MERGE_OVERWRITE_VALUES | MERGE_PREPEND_LISTS | |
| 170 | 170 |
| 171 | 171 |
| 172 def merge_dicts(source, merging, *args, | 172 def merge_dicts(source, merging, *args, |
| 173 validator=None, mode=MERGE_ALL): | 173 validator=None, mode=MERGE_ALL): |
| 174 _recurse_merge_dicts(source, merging, None, validator, mode) | 174 _recurse_merge_dicts(source, merging, None, validator, mode) |
