archivebox.config.configset
Simplified config system for ArchiveBox.
This replaces the complex abx_spec_config/base_configset.py with a simpler approach that still supports environment variables, config files, and per-object overrides.
Module Contents
Classes
Custom settings source that reads from ArchiveBox.conf (INI format). Flattens all sections into a single namespace. |
|
Base class for config sections. |
Functions
Get merged config from all sources. |
|
Get a flat dictionary of all config values. |
|
Get all config section objects as a dictionary. |
|
Parse an environment variable value based on expected type. |
|
Get worker concurrency settings. |
Data
API
- 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
- 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.
- class archivebox.config.configset.BaseConfigSet[source]
Bases:
pydantic_settings.BaseSettingsBase class for config sections.
Automatically loads values from (highest to lowest priority):
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).
- archivebox.config.configset.get_config(defaults: dict | None = None, persona: Any = None, user: Any = None, crawl: Any = None, snapshot: Any = None, archiveresult: Any = None, machine: Any = None) dict[str, Any][source]
Get merged config from all sources.
Priority (highest to lowest):
Per-snapshot config (snapshot.config JSON field)
Per-crawl config (crawl.config JSON field)
Per-user config (user.config JSON field)
Per-persona config (persona.get_derived_config() - includes CHROME_USER_DATA_DIR etc.)
Environment variables
Config file (ArchiveBox.conf)
Plugin schema defaults (config.json)
Core config defaults
Args: defaults: Default values to start with persona: Persona object (provides derived paths like CHROME_USER_DATA_DIR) user: User object with config JSON field crawl: Crawl object with config JSON field snapshot: Snapshot object with config JSON field archiveresult: ArchiveResult object (auto-fetches snapshot) machine: Unused legacy argument kept for call compatibility
Note: Objects are auto-fetched from relationships if not provided: - snapshot auto-fetched from archiveresult.snapshot - crawl auto-fetched from snapshot.crawl - user auto-fetched from crawl.created_by
Returns: Merged config dict
- archivebox.config.configset.get_flat_config() dict[str, Any][source]
Get a flat dictionary of all config values.
Replaces abx.pm.hook.get_FLAT_CONFIG()
- archivebox.config.configset.get_all_configs() dict[str, archivebox.config.configset.BaseConfigSet][source]
Get all config section objects as a dictionary.
Replaces abx.pm.hook.get_CONFIGS()