MCPcopy
hub / github.com/borgbackup/borg / get_config_dir

Function get_config_dir

src/borg/helpers/fs.py:164–181  ·  view source on GitHub ↗

Determine where to store the configuration.

(*, legacy=False, create=True)

Source from the content-addressed store, hash-verified

162
163
164def get_config_dir(*, legacy=False, create=True):
165 """Determine where to store the configuration."""
166
167 # Get config home path
168 if legacy:
169 config_home = join_base_dir(".config", legacy=legacy)
170 # Try to use XDG_CONFIG_HOME instead if BORG_BASE_DIR isn't explicitly set
171 if not os.environ.get("BORG_BASE_DIR"):
172 config_home = os.environ.get("XDG_CONFIG_HOME", config_home)
173 # Use BORG_CONFIG_DIR if set, otherwise assemble final path from config home path
174 config_dir = os.environ.get("BORG_CONFIG_DIR", str(Path(config_home) / "borg"))
175 else:
176 config_dir = os.environ.get(
177 "BORG_CONFIG_DIR", join_base_dir(".config", "borg", legacy=legacy) or platformdirs.user_config_dir("borg")
178 )
179 if create:
180 ensure_dir(config_dir)
181 return config_dir
182
183
184def dir_is_cachedir(path=None, dir_fd=None):

Callers 4

get_keys_dirFunction · 0.85
build_parserMethod · 0.85
test_get_config_dirFunction · 0.85

Calls 3

join_base_dirFunction · 0.85
ensure_dirFunction · 0.85
getMethod · 0.45

Tested by 2

test_get_config_dirFunction · 0.68