abx_spec_config.base_configset

Module Contents

Classes

FlatTomlConfigSettingsSource

A source class that loads variables from a TOML file

BaseConfigSet

This is the base class for an ArchiveBox ConfigSet. It handles loading values from schema defaults, ArchiveBox.conf TOML config, and environment variables.

Functions

func_takes_args_or_kwargs

returns True if a lambda func takes args/kwargs of any kind, otherwise false if it’s pure/argless

convert_ini_to_toml

Convert an INI file to a TOML file, saving the original to .ORIGINALNAME.bak

Data

AUTOFIXES_HEADER

AUTOFIXES_SUBHEADER

_ALREADY_WARNED_ABOUT_UPDATED_CONFIG

ConfigKeyStr

API

abx_spec_config.base_configset.AUTOFIXES_HEADER[source]

‘[AUTOFIXES]’

abx_spec_config.base_configset.AUTOFIXES_SUBHEADER[source]

‘# The following config was added automatically to fix problems detected at startup:’

abx_spec_config.base_configset._ALREADY_WARNED_ABOUT_UPDATED_CONFIG[source]

‘set(…)’

abx_spec_config.base_configset.ConfigKeyStr[source]

None

class abx_spec_config.base_configset.FlatTomlConfigSettingsSource(settings_cls: type[pydantic_settings.BaseSettings], toml_file: pathlib.Path | None = None)[source]

Bases: pydantic_settings.sources.TomlConfigSettingsSource

A source class that loads variables from a TOML file

Initialization

class abx_spec_config.base_configset.BaseConfigSet[source]

Bases: pydantic_settings.BaseSettings

This is the base class for an ArchiveBox ConfigSet. It handles loading values from schema defaults, ArchiveBox.conf TOML config, and environment variables.

class WgetConfig(ArchiveBoxBaseConfig): WGET_BINARY: str = Field(default=’wget’, alias=’WGET_BINARY_PATH’)

c = WgetConfig() print(c.WGET_BINARY) # outputs: wget

you can mutate process environment variable and reload config using .init()

os.environ[‘WGET_BINARY_PATH’] = ‘wget2’ c.init()

print(c.WGET_BINARY) # outputs: wget2

model_config[source]

‘SettingsConfigDict(…)’

load_from_defaults: ClassVar[bool][source]

True

load_from_system: ClassVar[bool][source]

True

load_from_collection: ClassVar[bool][source]

True

load_from_environment: ClassVar[bool][source]

True

classmethod settings_customise_sources(settings_cls: Type[pydantic_settings.BaseSettings], init_settings: pydantic_settings.PydanticBaseSettingsSource, env_settings: pydantic_settings.PydanticBaseSettingsSource, dotenv_settings: pydantic_settings.PydanticBaseSettingsSource, file_secret_settings: pydantic_settings.PydanticBaseSettingsSource) Tuple[pydantic_settings.PydanticBaseSettingsSource, ...][source]

Defines the config precedence order: Schema defaults -> ArchiveBox.conf (TOML) -> Environment variables

fill_defaults()[source]

Populate any unset values using function provided as their default

validate()[source]

Manual validation method, to be called from plugin/init.py:get_CONFIG()

get_default_value(key: abx_spec_config.base_configset.ConfigKeyStr)[source]

Get the default value for a given config key

update_in_place(warn=False, persist=False, hint='', **kwargs)[source]

Update the config with new values. Use this sparingly! We should almost never be updating config at runtime. Sets them in the environment so they propagate to spawned subprocesses / across future re-init()s and reload from environment

Example acceptable use case: user config says SEARCH_BACKEND_ENGINE=sonic but sonic_client pip library is not installed so we cannot use it. SEARCH_BACKEND_CONFIG.update_in_place(SEARCH_BACKEND_ENGINE=’ripgrep’) can be used to reset it back to ripgrep so we can continue.

property aliases: Dict[abx_spec_config.base_configset.ConfigKeyStr, abx_spec_config.base_configset.ConfigKeyStr][source]
property toml_section_header[source]

Convert the class name to a TOML section header e.g. ShellConfig -> SHELL_CONFIG

from_defaults() Dict[abx_spec_config.base_configset.ConfigKeyStr, Any][source]

Get the dictionary of {key: value} config loaded from the default values

from_collection() Dict[abx_spec_config.base_configset.ConfigKeyStr, Any][source]

Get the dictionary of {key: value} config loaded from the collection ArchiveBox.conf

from_environment() Dict[abx_spec_config.base_configset.ConfigKeyStr, Any][source]

Get the dictionary of {key: value} config loaded from the environment variables

from_computed() Dict[abx_spec_config.base_configset.ConfigKeyStr, Any][source]

Get the dictionary of {key: value} config loaded from the computed fields

to_toml_dict(defaults=False) Dict[abx_spec_config.base_configset.ConfigKeyStr, Any][source]

Get the current config as a TOML-ready dict

to_toml_str(defaults=False) str[source]

Get the current config as a TOML string

abx_spec_config.base_configset.func_takes_args_or_kwargs(lambda_func: Callable[..., Any]) bool[source]

returns True if a lambda func takes args/kwargs of any kind, otherwise false if it’s pure/argless

abx_spec_config.base_configset.convert_ini_to_toml(ini_file: pathlib.Path)[source]

Convert an INI file to a TOML file, saving the original to .ORIGINALNAME.bak