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 (type: string)
Instance Variable prefix prefix to prepend to all commandline options (type: string)
Instance Variable config current configuration parameters (type: dict)
Class Variable defaults defaults value of an option if not in the config file or given on the command line (type: dict)
Class Variable help help messages (type: dict)
Class Variable def_config_files config files we parse (type: dict (type, path))
Class Method get_config_files Get list of config files from the GBP_CONF_FILES environment variable.
Method config_file_sections List of all found config file sections
Method parse_lists Parse options that can be given as lists
Method parse_config_files Parse the possible config files and set appropriate values default values
Method __init__ No summary
Method get_default get the default value
Method get_opt_names Undocumented
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 print_help Print an extended help message, listing all options and any help text provided with them, to 'file' (default stdout).
Method _read_config_file Read config file
Method _warn_old_config_section Undocumented
Method _warn_old_gbp_conf Undocumented
Static Method _listify No summary
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
Class Method _name_to_filename Translate a name like 'system' to a config file name
Class Method _set_config_file_value Write a config value to a file creating it if needed
command =
the gbp command we store the options for (type: string)
prefix =
prefix to prepend to all commandline options (type: string)
config =
current configuration parameters (type: dict)
defaults =
defaults value of an option if not in the config file or given on the command line (type: dict)
help =
help messages (type: dict)
def_config_files =
config files we parse (type: dict (type, path))
@classmethod
def get_config_files(cls, no_local=False):

Get list of config files from the GBP_CONF_FILES environment variable.

Parametersno_localdon't return the per-repo configuration files (type: bool)
Returnslist of config files we need to parse (type: list
>>> import re
>>> 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 = [re.sub("^%s" % homedir, 'HOME', file) for file in files]
>>> sorted(files_mangled)
['%(git_dir)s/gbp.conf', '%(top_dir)s/.gbp.conf', '%(top_dir)s/debian/gbp.conf', '/etc/git-buildpackage/gbp.conf', 'HOME/.gbp.conf']
>>> files = GbpOptionParser.get_config_files(no_local=True)
>>> files_mangled = [re.sub("^%s" % homedir, 'HOME', file) for file in files]
>>> sorted(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
)
def _read_config_file(self, repo, filename):

Read config file

def _warn_old_config_section(self, oldcmd, cmd):
Undocumented
def _warn_old_gbp_conf(self, gbp_conf):
@property
def config_file_sections(self):

List of all found config file sections

@staticmethod
def _listify(value):
>>> GbpOptionParser._listify(None)
[]
>>> GbpOptionParser._listify('string')
['string']
>>> GbpOptionParser._listify('["q", "e", "d"] ')
['q', 'e', 'd']
>>> GbpOptionParser._listify('[')
Traceback (most recent call last):
...
configparser.Error: [ is not a proper list
def parse_lists(self):

Parse options that can be given as lists

Since they take multiple arguments they can also be given in plural form e.g. components instead of component.

def parse_config_files(self):

Parse the possible config files and set appropriate values default values

def __init__(self, command, prefix='', usage=None, sections=[]):
Parameterscommandthe command to build the config parser for (type: str)
prefixA prefix to add to all command line options (type: str)
usagea usage description (type: str)
sectionsadditional (non optional) config file sections to parse (type: list of str)
def _is_boolean(self, dummy, *unused, **kwargs):

is option_name a boolean option

def _get_bool_default(self, option_name):

get default for boolean options this way we can handle no-foo=True and foo=False

def get_default(self, option_name, **kwargs):

get the default value

def get_opt_names(self, option_name):
Undocumented
@save_option
def add_config_file_option(self, option_name, dest, help=None, **kwargs):

set a option for the command line parser, the default is read from the config file param option_name: name of the option type option_name: string param dest: where to store this option type dest: string param help: help text type help: string

def add_boolean_config_file_option(self, option_name, dest):
Undocumented
def get_config_file_value(self, option_name):

Query a single interpolated config file value.

Parametersoption_namethe config file option to look up (type: string)
ReturnsThe config file option value or None if it doesn't exist (type: str or None)
def print_help(self, file=None):

Print an extended help message, listing all options and any help text provided with them, to 'file' (default stdout).

@classmethod
def _name_to_filename(cls, name):

Translate a name like 'system' to a config file name

>>> GbpOptionParser._name_to_filename('foo')
>>> GbpOptionParser._name_to_filename('system')
'/etc/git-buildpackage/gbp.conf'
>>> GbpOptionParser._name_to_filename('global')
'~/.gbp.conf'
>>> GbpOptionParser._name_to_filename('debian')
'%(top_dir)s/debian/gbp.conf'
@classmethod
def _set_config_file_value(cls, section, option, value, name=None, filename=None):

Write a config value to a file creating it if needed

On errors a ConfigParserError is raised

API Documentation for git-buildpackage, generated by pydoctor at 2018-08-19 08:52:02.