diff options
author | Guido Guenther <agx@sigxcpu.org> | 2008-04-26 02:26:55 +0200 |
---|---|---|
committer | Guido Guenther <agx@sigxcpu.org> | 2008-04-26 02:26:55 +0200 |
commit | 720ad47a7bd6b44f5fb74409ca5770e3f134df0a (patch) | |
tree | bac1da55e56076672a0c028a8b41c6f28bc1c1c6 /gbp | |
parent | 36889d7b1eb611cc6bd39e03d55de11d2d309e62 (diff) |
make boolean options parsing more robust
Diffstat (limited to 'gbp')
-rw-r--r-- | gbp/config.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/gbp/config.py b/gbp/config.py index c18fc283..0c58681b 100644 --- a/gbp/config.py +++ b/gbp/config.py @@ -27,9 +27,9 @@ class GbpOptionParser(OptionParser): 'cleaner' : 'debuild clean', 'debian-branch' : 'master', 'upstream-branch' : 'upstream', - 'pristine-tar' : '', # empty means False - 'sign-tags' : '', # empty means False - 'no-create-orig' : '', # empty means False + 'pristine-tar' : 'False', + 'sign-tags' : 'False', + 'no-create-orig' : 'False', 'keyid' : '', 'posttag' : '', 'debian-tag' : 'debian/%(version)s', @@ -39,6 +39,7 @@ class GbpOptionParser(OptionParser): 'git-log' : '--no-merges', 'export-dir' : '', 'tarball-dir' : '', + 'ignore-new' : 'False', } config_files = [ '/etc/git-buildpackage/gbp.conf', os.path.expanduser('~/.gbp.conf'), @@ -77,8 +78,15 @@ class GbpOptionParser(OptionParser): @var help: help text @type help: string """ + default = self.config[option_name] + if kwargs.has_key('action'): + if kwargs['action'] in [ 'store_true', 'store_false'] and self.config[option_name]: + if self.config[option_name] in [ 'True', 'False']: + default = eval(self.config[option_name]) + else: + raise Exception, "Boolean options must be True or False" OptionParser.add_option(self,"--%s%s" % (self.prefix, option_name), dest=dest, - default=self.config[option_name], + default=default, help=help % self.config, **kwargs) # vim:et:ts=4:sw=4:et:sts=4:ai:set list listchars=tab\:»·,trail\:·: |