config.py

1import os
2
3def check_env(input):
4    return os.getenv(input, None)
5
6account_dir = os.path.join(check_env('GIT_ACCOUNT_DIR'), '.accounts.creds') or os.path.join("data", ".accounts.creds")
7
8user_profile = os.getenv('USERPROFILE', 'C:\\Users\\Default')
9home_dir = os.getenv('HOME', f'/home/{os.getenv("USER", "default")}')
10
11git_config_paths = {
12    'nt': os.path.join(user_profile, ".gitconfig"),
13    'posix': os.path.join(home_dir, ".gitconfig"),
14    'darwin': os.path.join(home_dir, ".gitconfig")
15}
16
17git_credentials_paths = {
18    'nt': os.path.join(user_profile, ".git-credentials"),
19    'posix': os.path.join(home_dir, ".git-credentials"),
20    'darwin': os.path.join(home_dir, ".git-credentials")
21}
22
23def get_git_config_path():
24    return git_config_paths.get(os.name, home_dir)
25
26def get_git_credentials_path():
27    return git_credentials_paths.get(os.name, home_dir)
28