comparison piecrust/commands/builtin/info.py @ 107:10fc9c8bf682

Better support for times in YAML interop. * Use our own sexagesimal parser/dumper for YAML to properly parse times. * Better name for the custom parser/dumper classes. * Add unit tests.
author Ludovic Chabant <ludovic@chabant.com>
date Wed, 15 Oct 2014 23:01:05 -0700
parents 474c9882decf
children 516db87a04d4
comparison
equal deleted inserted replaced
106:5effaf1978d0 107:10fc9c8bf682
1 import os.path 1 import os.path
2 import logging 2 import logging
3 import fnmatch 3 import fnmatch
4 from piecrust.commands.base import ChefCommand 4 from piecrust.commands.base import ChefCommand
5 from piecrust.configuration import ConfigurationDumper
5 6
6 7
7 logger = logging.getLogger(__name__) 8 logger = logging.getLogger(__name__)
8 9
9 10
34 def run(self, ctx): 35 def run(self, ctx):
35 show = ctx.app.config.get(ctx.args.path) 36 show = ctx.app.config.get(ctx.args.path)
36 if show is not None: 37 if show is not None:
37 if isinstance(show, (dict, list)): 38 if isinstance(show, (dict, list)):
38 import yaml 39 import yaml
39 out = yaml.safe_dump(show, default_flow_style=False) 40 out = yaml.dump(show, default_flow_style=False,
41 Dumper=ConfigurationDumper)
40 logger.info(out) 42 logger.info(out)
41 else: 43 else:
42 logger.info(show) 44 logger.info(show)
43 elif ctx.args.path: 45 elif ctx.args.path:
44 logger.error("No such configuration path: %s" % ctx.args.path) 46 logger.error("No such configuration path: %s" % ctx.args.path)