Mercurial > piecrust2
comparison piecrust/configuration.py @ 301:45aba3cb7228
config: Make YAML consider `omap` structures as normal maps.
| author | Ludovic Chabant <ludovic@chabant.com> |
|---|---|
| date | Thu, 19 Mar 2015 18:28:42 -0700 |
| parents | f98451237371 |
| children | 734f2abf361c |
comparison
equal
deleted
inserted
replaced
| 300:2daa05a21026 | 301:45aba3cb7228 |
|---|---|
| 217 ch_resolvers.insert(0, ch_resolvers.pop()) | 217 ch_resolvers.insert(0, ch_resolvers.pop()) |
| 218 | 218 |
| 219 | 219 |
| 220 class ConfigurationDumper(yaml.SafeDumper): | 220 class ConfigurationDumper(yaml.SafeDumper): |
| 221 def represent_ordered_dict(self, data): | 221 def represent_ordered_dict(self, data): |
| 222 return self.represent_mapping('tag:yaml.org,2002:omap', data) | 222 # Not a typo: we're using `map` and not `omap` because we don't want |
| 223 # ugly type tags printed in the generated YAML markup, and because | |
| 224 # we always load maps into `OrderedDicts` anyway. | |
| 225 return self.represent_mapping('tag:yaml.org,2002:map', data) | |
| 223 | 226 |
| 224 | 227 |
| 225 ConfigurationDumper.add_representer(collections.OrderedDict, | 228 ConfigurationDumper.add_representer(collections.OrderedDict, |
| 226 ConfigurationDumper.represent_ordered_dict) | 229 ConfigurationDumper.represent_ordered_dict) |
| 227 | 230 |
