archivebox.config.configset
Pydantic-backed config loading for ArchiveBox.
Module Contents
Classes
Custom settings source that reads from ArchiveBox.conf (INI format). Flattens all sections into a single namespace. |
|
Pure typed runtime model for config sections. |
Functions
Read and flatten an ArchiveBox INI config file. |
|
Return a JSON decoder and the dict/list-typed field names for a config model. |
|
Decode string-only config values once at the boundary to typed config. |
Data
API
- archivebox.config.configset.COMPUTED_CONFIG_KEYS[source]
(‘TERM_WIDTH’, ‘COMMIT_HASH’, ‘BUILD_TIME’, ‘USES_SUBDOMAIN_ROUTING’, ‘ENABLES_FULL_JS_REPLAY’, ‘CON…
- class archivebox.config.configset.CaseConfigParser(defaults=None, dict_type=_default_dict, allow_no_value=False, *, delimiters=('=', ':'), comment_prefixes=('#', ';'), inline_comment_prefixes=None, strict=True, empty_lines_in_values=True, default_section=DEFAULTSECT, interpolation=_UNSET, converters=_UNSET)[source]
Bases:
configparser.ConfigParser
- archivebox.config.configset._PARSED_INI_CONFIG: tuple[pathlib.Path, str, dict[str, Any]] | None[source]
None
- archivebox.config.configset.read_ini_config(config_path: str | pathlib.Path) dict[str, Any][source]
Read and flatten an ArchiveBox INI config file.
- class archivebox.config.configset.IniConfigSettingsSource[source]
Bases:
pydantic_settings.PydanticBaseSettingsSourceCustom settings source that reads from ArchiveBox.conf (INI format). Flattens all sections into a single namespace.
- archivebox.config.configset._config_decoder(settings_cls: type[pydantic.BaseModel]) tuple[archivebox.config.configset.IniConfigSettingsSource, frozenset[str]][source]
Return a JSON decoder and the dict/list-typed field names for a config model.
Both depend only on the class’s fields, which are fixed once the model is built, yet building the source and classifying every annotation cost more than the decoding itself on each get_config() call.
- archivebox.config.configset.decode_config_inputs(settings_cls: type[pydantic.BaseModel], config: collections.abc.Mapping[str, Any], *, decode_unknown_json: bool = False) dict[str, Any][source]
Decode string-only config values once at the boundary to typed config.
- class archivebox.config.configset.BaseConfigSet[source]
Bases:
pydantic.BaseModelPure typed runtime model for config sections.
Source-loading subclasses combine this model with
BaseSettingsand load:Environment variables
ArchiveBox.conf file (INI format, flattened)
Default values
Subclasses define fields with defaults and types:
class ShellConfig(BaseConfigSet): DEBUG: bool = Field(default=False) USE_COLOR: bool = Field(default=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]
Define the order of settings sources (first = highest priority).