gbp.config.GbpOptionParser(OptionParser)
class documentationgbp.config
(View In Hierarchy)
Known subclasses: gbp.config.GbpOptionParserDebian, gbp.config.GbpOptionParserRpm
Handles commandline options and parsing of config files
Instance Variable | command | the gbp command we store the options for |
Instance Variable | prefix | prefix to prepend to all commandline options |
Instance Variable | config | current configuration parameters |
Class Variable | defaults | defaults value of an option if not in the config file or given on the command line |
Class Variable | help | help messages |
Class Variable | def_config_files | list of default config files we parse |
Class Method | get_config_files | Get list of config files from the GBP_CONF_FILES environment variable. |
Method | parse_config_files | Parse the possible config files and set appropriate values default values |
Method | __init__ | No summary |
Instance Variable | sections | Undocumented |
Instance Variable | valid_options | Undocumented |
Method | get_default | get the default value |
Method | add_config_file_option | No summary |
Method | add_boolean_config_file_option | Undocumented |
Method | get_config_file_value | Query a single interpolated config file value. |
Method | _read_config_file | Read config file |
Method | _is_boolean | is option_name a boolean option |
Method | _get_bool_default | get default for boolean options this way we can handle no-foo=True and foo=False |
Get list of config files from the GBP_CONF_FILES environment variable.
Parameters | no_local | don't return the per-repo configuration files (type: str ) |
Returns | list of config files we need to parse (type: list >>> conf_backup = os.getenv('GBP_CONF_FILES') >>> if conf_backup is not None: del os.environ['GBP_CONF_FILES'] >>> homedir = os.path.expanduser("~") >>> files = GbpOptionParser.get_config_files() >>> files_mangled = [file.replace(homedir, 'HOME') for file in files] >>> files_mangled ['/etc/git-buildpackage/gbp.conf', 'HOME/.gbp.conf', '%(top_dir)s/.gbp.conf', '%(top_dir)s/debian/gbp.conf', '%(git_dir)s/gbp.conf'] >>> files = GbpOptionParser.get_config_files(no_local=True) >>> files_mangled = [file.replace(homedir, 'HOME') for file in files] >>> files_mangled ['/etc/git-buildpackage/gbp.conf', 'HOME/.gbp.conf'] >>> os.environ['GBP_CONF_FILES'] = 'test1:test2' >>> GbpOptionParser.get_config_files() ['test1', 'test2'] >>> del os.environ['GBP_CONF_FILES'] >>> if conf_backup is not None: os.environ['GBP_CONF_FILES'] = conf_backup) |
Parse the possible config files and set appropriate values default values
Parameters | command | the command to build the config parser for (type: str ) |
prefix | A prefix to add to all command line options (type: str ) | |
usage | a usage description (type: str ) | |
sections | additional (non optional) config file sections to parse (type: list of str ) |
get default for boolean options this way we can handle no-foo=True and foo=False