class documentation

A Git configuration file, like .git/config or ~/.gitconfig.

Class Method from_file Read configuration from a file-like object.
Class Method from_path Read configuration from a file on disk.
Method __init__ Initialize a ConfigFile.
Method write_to_file Write configuration to a file-like object.
Method write_to_path Write configuration to a file on disk.
Instance Variable path Undocumented
Method _evaluate_hasconfig_condition Evaluate a hasconfig condition.
Method _evaluate_includeif_condition Evaluate an includeIf condition.
Method _handle_include_directive Handle include/includeIf directives during config parsing.
Method _match_hasconfig_pattern Match a config value against a hasconfig pattern.
Method _merge_config Merge another config file into this one.
Method _process_include Process an include or includeIf directive.
Method _resolve_include_path Resolve an include path to an absolute path.
Instance Variable _included_paths Undocumented

Inherited from ConfigDict:

Method __delitem__ Delete a configuration section.
Method __eq__ Check equality with another ConfigDict.
Method __getitem__ Get configuration values for a section.
Method __iter__ Iterate over configuration sections.
Method __len__ Return the number of sections.
Method __repr__ Return string representation of ConfigDict.
Method __setitem__ Set configuration values for a section.
Method add Add a value to a configuration setting, creating a multivar if needed.
Method get Get a configuration value.
Method get_multivar Get multiple values for a configuration setting.
Method items Get items in a section.
Method keys Return a view of section names.
Method remove Remove a configuration setting.
Method sections Get all sections.
Method set Set a configuration value.
Instance Variable encoding Undocumented
Class Method _parse_setting Undocumented
Method _check_section_and_name Undocumented
Instance Variable _values Undocumented

Inherited from Config (via ConfigDict):

Method get_boolean Retrieve a configuration setting as boolean.
Method has_section Check if a specified section exists.
def from_file(cls, f: IO[bytes], *, config_dir: str | None = None, included_paths: set[str] | None = None, include_depth: int = 0, max_include_depth: int = DEFAULT_MAX_INCLUDE_DEPTH, file_opener: FileOpener | None = None, condition_matchers: Mapping[str, ConditionMatcher] | None = None) -> ConfigFile:

Read configuration from a file-like object.

Parameters
f:IO[bytes]File-like object to read from
config_dir:str | NoneDirectory containing the config file (for relative includes)
included_paths:set[str] | NoneSet of already included paths (to prevent cycles)
include_depth:intCurrent include depth (to prevent infinite recursion)
max_include_depth:intMaximum allowed include depth
file_opener:FileOpener | NoneOptional callback to open included files
condition_matchers:Mapping[str, ConditionMatcher] | NoneOptional dict of condition matchers for includeIf
Returns
ConfigFileUndocumented
def from_path(cls, path: str | os.PathLike[str], *, max_include_depth: int = DEFAULT_MAX_INCLUDE_DEPTH, file_opener: FileOpener | None = None, condition_matchers: Mapping[str, ConditionMatcher] | None = None) -> ConfigFile:

Read configuration from a file on disk.

Parameters
path:str | os.PathLike[str]Path to the configuration file
max_include_depth:intMaximum allowed include depth
file_opener:FileOpener | NoneOptional callback to open included files
condition_matchers:Mapping[str, ConditionMatcher] | NoneOptional dict of condition matchers for includeIf
Returns
ConfigFileUndocumented
def __init__(self, values: MutableMapping[Section, CaseInsensitiveOrderedMultiDict[Name, Value]] | None = None, encoding: str | None = None):

Initialize a ConfigFile.

Parameters
values:MutableMapping[Section, CaseInsensitiveOrderedMultiDict[Name, Value]] | NoneOptional mapping of configuration values
encoding:str | NoneOptional encoding for the file (defaults to system encoding)
def write_to_file(self, f: IO[bytes] | _GitFile):

Write configuration to a file-like object.

def write_to_path(self, path: str | os.PathLike[str] | None = None):

Write configuration to a file on disk.

path: str | None =

Undocumented

def _evaluate_hasconfig_condition(self, condition: str) -> bool:

Evaluate a hasconfig condition.

Format: hasconfig:config.key:pattern Example: hasconfig:remote.*.url:ssh://org-@github.com/*

def _evaluate_includeif_condition(self, condition: str, config_dir: str | None = None, condition_matchers: Mapping[str, ConditionMatcher] | None = None) -> bool:

Evaluate an includeIf condition.

def _handle_include_directive(self, section: Section | None, setting: bytes, value: bytes, *, config_dir: str | None, include_depth: int, max_include_depth: int, file_opener: FileOpener | None, condition_matchers: Mapping[str, ConditionMatcher] | None):

Handle include/includeIf directives during config parsing.

def _match_hasconfig_pattern(self, value: bytes, pattern: str) -> bool:

Match a config value against a hasconfig pattern.

Supports simple glob patterns like * and **.

def _merge_config(self, other: ConfigFile):

Merge another config file into this one.

def _process_include(self, section: Section, path_value: bytes, *, config_dir: str | None, include_depth: int, max_include_depth: int, file_opener: FileOpener | None, condition_matchers: Mapping[str, ConditionMatcher] | None):

Process an include or includeIf directive.

def _resolve_include_path(self, path: str, config_dir: str | None) -> str | None:

Resolve an include path to an absolute path.

_included_paths: set[str] =

Undocumented