diff options
author | Guido Günther <agx@sigxcpu.org> | 2014-04-01 20:29:22 +0200 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2014-04-01 22:42:13 +0200 |
commit | 4c6b06773876a35f55f8f5667af65a917f823757 (patch) | |
tree | 8623bdccf7d7d1a0d559bdb8f38dae4af0e652f0 /gbp/config.py | |
parent | 03ada72d54480917c75e05568844e3f596e2cb64 (diff) | |
download | git-buildpackage-4c6b06773876a35f55f8f5667af65a917f823757.tar.gz git-buildpackage-4c6b06773876a35f55f8f5667af65a917f823757.tar.bz2 git-buildpackage-4c6b06773876a35f55f8f5667af65a917f823757.zip |
Add minimal 'config' command
This only allows to print single config values so far.
Closes: #733470
Diffstat (limited to 'gbp/config.py')
-rw-r--r-- | gbp/config.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/gbp/config.py b/gbp/config.py index 1980daac..710eddf8 100644 --- a/gbp/config.py +++ b/gbp/config.py @@ -305,7 +305,7 @@ class GbpOptionParser(OptionParser): files = envvar.split(':') if envvar else klass.def_config_files return [ os.path.expanduser(f) for f in files ] - def _parse_config_files(self): + def parse_config_files(self): """ Parse the possible config files and set appropriate values default values @@ -372,7 +372,7 @@ class GbpOptionParser(OptionParser): self.prefix = prefix self.config = {} self.config_files = self.get_config_files() - self._parse_config_files() + self.parse_config_files() if self.command.startswith('git-') or self.command.startswith('gbp-'): prog = self.command @@ -447,6 +447,17 @@ class GbpOptionParser(OptionParser): neg_help = "negates '--%s%s'" % (self.prefix, option_name) self.add_config_file_option(option_name="no-%s" % option_name, dest=dest, help=neg_help, action="store_false") + def get_config_file_value(self, option_name): + """ + Query a single interpolated config file value. + + @param option_name: the config file option to look up + @type option_name: string + @returns: The config file option value or C{None} if it doesn't exist + @rtype: C{str} or C{None} + """ + return self.config.get(option_name) + class GbpOptionGroup(OptionGroup): def add_config_file_option(self, option_name, dest, help=None, **kwargs): |