MCPcopy Index your code
hub / github.com/dbcli/mycli / read_config_files

Function read_config_files

mycli/config.py:53–78  ·  view source on GitHub ↗

Read and merge a list of config files.

(
    files: list[str | IO[str]],
    list_values: bool = True,
    ignore_package_defaults: bool = False,
    ignore_user_options: bool = False,
)

Source from the content-addressed store, hash-verified

51
52
53def read_config_files(
54 files: list[str | IO[str]],
55 list_values: bool = True,
56 ignore_package_defaults: bool = False,
57 ignore_user_options: bool = False,
58) -> ConfigObj:
59 """Read and merge a list of config files."""
60
61 if ignore_package_defaults:
62 config = ConfigObj()
63 else:
64 config = create_default_config(list_values=list_values)
65
66 if ignore_user_options:
67 return config
68
69 _files = copy(files)
70 while _files:
71 _file = _files.pop(0)
72 _config = read_config_file(_file, list_values=list_values)
73
74 if _config is not None:
75 config.merge(_config)
76 config.filename = _config.filename
77
78 return config
79
80
81def create_default_config(list_values: bool = True) -> ConfigObj:

Callers 1

__init__Method · 0.90

Calls 2

create_default_configFunction · 0.85
read_config_fileFunction · 0.85

Tested by

no test coverage detected