Skip to content

repo_on_fire.configuration

Functionality to handle configuration of the app.

Configuration

Bases: BaseSettings

Holds configurable application settings.

Source code in repo_on_fire/configuration.py
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
class Configuration(BaseSettings):
    """Holds configurable application settings."""

    model_config = SettingsConfigDict(env_prefix="rof_")
    """Model configuration."""

    cache_path: Path = Path(appdirs.user_cache_dir(appname=APP_NAME, appauthor=APP_AUTHOR))
    """The path to the app cache."""

    repo_url: Optional[str] = None
    """The URL to clone Google's repo tool from."""

    repo_rev: Optional[str] = None
    """The revision of Google's repo tool to use."""

    repo_script_url: str = "https://storage.googleapis.com/git-repo-downloads/repo"
    """The URL of repo's starter script."""

    workspace_cache_strategy: WorkspaceCacheStrategy = WorkspaceCacheStrategy.auto_sync
    """The strategy to use for maintaining the workspace cache."""

    http_proxy: Optional[str] = None
    """HTTP proxy to use for web requests."""

    https_proxy: Optional[str] = None
    """HTTPS proxy to use for web requests."""

    verify_https_requests: bool = True
    """If set to False, disable verification of HTTPS requests."""

    native_command_additional_arguments: Optional[Dict[str, List[str]]] = None
    """Additional arguments to pass to native repo commands.

    This map holds a list of additional arguments to be passed to native
    repo commands when invoking the.
    """

cache_path = Path(appdirs.user_cache_dir(appname=APP_NAME, appauthor=APP_AUTHOR)) class-attribute instance-attribute

The path to the app cache.

http_proxy = None class-attribute instance-attribute

HTTP proxy to use for web requests.

https_proxy = None class-attribute instance-attribute

HTTPS proxy to use for web requests.

model_config = SettingsConfigDict(env_prefix='rof_') class-attribute instance-attribute

Model configuration.

native_command_additional_arguments = None class-attribute instance-attribute

Additional arguments to pass to native repo commands.

This map holds a list of additional arguments to be passed to native repo commands when invoking the.

repo_rev = None class-attribute instance-attribute

The revision of Google's repo tool to use.

repo_script_url = 'https://storage.googleapis.com/git-repo-downloads/repo' class-attribute instance-attribute

The URL of repo's starter script.

repo_url = None class-attribute instance-attribute

The URL to clone Google's repo tool from.

verify_https_requests = True class-attribute instance-attribute

If set to False, disable verification of HTTPS requests.

workspace_cache_strategy = WorkspaceCacheStrategy.auto_sync class-attribute instance-attribute

The strategy to use for maintaining the workspace cache.

get_user_config_file_path()

Get the path to the user app configuration.

Source code in repo_on_fire/configuration.py
58
59
60
61
62
63
64
65
66
67
68
def get_user_config_file_path() -> Path:
    """Get the path to the user app configuration."""
    # Check if the user wants to force use of a specific file:
    if CONFIG_FILE_NAME_ENV_VAR in os.environ:
        return Path(os.environ[CONFIG_FILE_NAME_ENV_VAR])

    # If not, assume the file to be in the user's config dir:
    sys_conf_dir = appdirs.user_config_dir(appname=APP_NAME, appauthor=APP_AUTHOR)
    sys_conf_path = Path(sys_conf_dir)
    sys_conf_file_path = sys_conf_path / CONFIG_FILE_NAME
    return sys_conf_file_path

load_configuration()

Load app configuration.

This loads the configuration of the app. Currently, this checks if a config file in a OS specific folder is present and tries to read the configuration from there. Otherwise, settings will be read from the environment. Finally, if neither is present, settings are taken from sane built-ins.

Source code in repo_on_fire/configuration.py
71
72
73
74
75
76
77
78
79
80
81
82
83
84
def load_configuration() -> Configuration:
    """Load app configuration.

    This loads the configuration of the app. Currently, this checks if a
    config file in a OS specific folder is present and tries to read the
    configuration from there. Otherwise, settings will be read from the
    environment. Finally, if neither is present, settings are taken from
    sane built-ins.
    """
    user_conf_path = get_user_config_file_path()
    if user_conf_path.exists():
        data = tomlkit.loads(user_conf_path.read_text(encoding="utf-8"))
        return Configuration(**data)
    return Configuration()