Mercurial > hg > configuration
changeset 90:6bf4a58b0988
make dump behave better
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Sat, 28 Apr 2012 22:55:39 -0700 |
parents | 0804a706d6bf |
children | 1e06fd17b8ad |
files | configuration/configuration.py |
diffstat | 1 files changed, 12 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/configuration/configuration.py Sat Apr 28 15:29:57 2012 -0700 +++ b/configuration/configuration.py Sat Apr 28 22:55:39 2012 -0700 @@ -272,8 +272,11 @@ # add an option for dumping formats = self.formats() if formats and dump: - self.add_option(dump, dest='dump', - help="dump configuration to a file; Formats: %s" % formats) + if isinstance(dump, basestring): + dump = [dump] + dump = list(dump) + self.add_option(*dump, dest='dump', + help="Output configuration file; Formats: %s" % formats) ### methods for iteration @@ -405,11 +408,6 @@ # errors are handled below pass - # dump configuration, if specified - dump = getattr(options, 'dump') - if dump: - # TODO: have a way of specifying format other than filename - self.serialize(dump) if missingvalues and not dump: # XXX assuming if you don't have values you were just dumping @@ -421,6 +419,13 @@ # return parsed arguments return options, args + def dump(self, options): + """dump configuration, if specified""" + dump = getattr(options, 'dump') + if dump: + # TODO: have a way of specifying format other than filename + self.serialize(dump) + ### serialization/deserialization def formats(self):