dulwich.config module¶
Reading and writing Git configuration files.
- class dulwich.config.CaseInsensitiveOrderedMultiDict¶
Bases:
MutableMapping
- get(k[, d]) D[k] if k in D, else d. d defaults to None. ¶
- get_all(key)¶
- items() a set-like object providing a view on D's items ¶
- keys() a set-like object providing a view on D's keys ¶
- classmethod make(dict_in=None)¶
- setdefault(k[, d]) D.get(k,d), also set D[k]=d if k not in D ¶
- values() an object providing a view on D's values ¶
- class dulwich.config.Config¶
Bases:
object
A Git configuration.
- get(section: Union[bytes, str, Tuple[Union[bytes, str], ...]], name: Union[bytes, str]) bytes ¶
Retrieve the contents of a configuration setting.
- Parameters
section – Tuple with section name and optional subsection name
name – Variable name
- Returns
Contents of the setting
- Raises
KeyError – if the value is not set
- get_boolean(section: Union[bytes, str, Tuple[Union[bytes, str], ...]], name: Union[bytes, str], default: bool) bool ¶
- get_boolean(section: Union[bytes, str, Tuple[Union[bytes, str], ...]], name: Union[bytes, str]) Optional[bool]
Retrieve a configuration setting as boolean.
- Parameters
section – Tuple with section name and optional subsection name
name – Name of the setting, including section and possible subsection.
- Returns
Contents of the setting
- get_multivar(section: Union[bytes, str, Tuple[Union[bytes, str], ...]], name: Union[bytes, str]) Iterator[bytes] ¶
Retrieve the contents of a multivar configuration setting.
- Parameters
section – Tuple with section name and optional subsection namee
name – Variable name
- Returns
Contents of the setting as iterable
- Raises
KeyError – if the value is not set
- has_section(name: Tuple[bytes, ...]) bool ¶
Check if a specified section exists.
- Parameters
name – Name of section to check for
- Returns
boolean indicating whether the section exists
- items(section: Union[bytes, str, Tuple[Union[bytes, str], ...]]) Iterator[Tuple[bytes, bytes]] ¶
Iterate over the configuration pairs for a specific section.
- Parameters
section – Tuple with section name and optional subsection namee
- Returns
Iterator over (name, value) pairs
- sections() Iterator[Tuple[bytes, ...]] ¶
Iterate over the sections.
Returns: Iterator over section tuples
- set(section: Union[bytes, str, Tuple[Union[bytes, str], ...]], name: Union[bytes, str], value: Union[bytes, str, bool]) None ¶
Set a configuration value.
- Parameters
section – Tuple with section name and optional subsection namee
name – Name of the configuration value, including section and optional subsection
value – value of the setting
- class dulwich.config.ConfigDict(values: Optional[MutableMapping[Tuple[bytes, ...], MutableMapping[bytes, bytes]]] = None, encoding: Optional[str] = None)¶
Bases:
Config
,MutableMapping
[Tuple
[bytes
, …],MutableMapping
[bytes
,bytes
]]Git configuration stored in a dictionary.
Create a new ConfigDict.
- get(section: Union[bytes, str, Tuple[Union[bytes, str], ...]], name: Union[bytes, str]) bytes ¶
Retrieve the contents of a configuration setting.
- Parameters
section – Tuple with section name and optional subsection name
name – Variable name
- Returns
Contents of the setting
- Raises
KeyError – if the value is not set
- get_multivar(section: Union[bytes, str, Tuple[Union[bytes, str], ...]], name: Union[bytes, str]) Iterator[bytes] ¶
Retrieve the contents of a multivar configuration setting.
- Parameters
section – Tuple with section name and optional subsection namee
name – Variable name
- Returns
Contents of the setting as iterable
- Raises
KeyError – if the value is not set
- items(section: Tuple[bytes, ...]) Iterator[Tuple[bytes, bytes]] ¶
Iterate over the configuration pairs for a specific section.
- Parameters
section – Tuple with section name and optional subsection namee
- Returns
Iterator over (name, value) pairs
- sections() Iterator[Tuple[bytes, ...]] ¶
Iterate over the sections.
Returns: Iterator over section tuples
- set(section: Union[bytes, str, Tuple[Union[bytes, str], ...]], name: Union[bytes, str], value: Union[bytes, str, bool]) None ¶
Set a configuration value.
- Parameters
section – Tuple with section name and optional subsection namee
name – Name of the configuration value, including section and optional subsection
value – value of the setting
- class dulwich.config.ConfigFile(values: Optional[MutableMapping[Tuple[bytes, ...], MutableMapping[bytes, bytes]]] = None, encoding: Optional[str] = None)¶
Bases:
ConfigDict
A Git configuration file, like .git/config or ~/.gitconfig.
Create a new ConfigDict.
- classmethod from_file(f: BinaryIO) ConfigFile ¶
Read configuration from a file-like object.
- classmethod from_path(path: str) ConfigFile ¶
Read configuration from a file on disk.
- class dulwich.config.StackedConfig(backends: List[ConfigFile], writable: Optional[ConfigFile] = None)¶
Bases:
Config
Configuration which reads from multiple config files..
- classmethod default() StackedConfig ¶
- classmethod default_backends() List[ConfigFile] ¶
Retrieve the default configuration.
See git-config(1) for details on the files searched.
- get(section: Union[bytes, str, Tuple[Union[bytes, str], ...]], name: Union[bytes, str]) bytes ¶
Retrieve the contents of a configuration setting.
- Parameters
section – Tuple with section name and optional subsection name
name – Variable name
- Returns
Contents of the setting
- Raises
KeyError – if the value is not set
- get_multivar(section: Union[bytes, str, Tuple[Union[bytes, str], ...]], name: Union[bytes, str]) Iterator[bytes] ¶
Retrieve the contents of a multivar configuration setting.
- Parameters
section – Tuple with section name and optional subsection namee
name – Variable name
- Returns
Contents of the setting as iterable
- Raises
KeyError – if the value is not set
- sections() Iterator[Tuple[bytes, ...]] ¶
Iterate over the sections.
Returns: Iterator over section tuples
- set(section: Union[bytes, str, Tuple[Union[bytes, str], ...]], name: Union[bytes, str], value: Union[bytes, str, bool]) None ¶
Set a configuration value.
- Parameters
section – Tuple with section name and optional subsection namee
name – Name of the configuration value, including section and optional subsection
value – value of the setting
- dulwich.config.apply_instead_of(config: Config, orig_url: str, push: bool = False) str ¶
Apply insteadOf / pushInsteadOf to a URL.
- dulwich.config.get_win_system_paths()¶
- dulwich.config.get_xdg_config_home_path(*path_segments)¶
- dulwich.config.iter_instead_of(config: Config, push: bool = False) Iterable[Tuple[str, str]] ¶
Iterate over insteadOf / pushInsteadOf values.
- dulwich.config.lower_key(key)¶