loader
onion_peeler.settings.loader
¶
ConfigLoader(config_dir=None, strict=True)
¶
Loads configuration from TOML files and validates with Pydantic.
Features: - Merges base.toml with site-specific configs - Environment variable overrides - Automatic validation - Helpful error messages
Initialize loader.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_dir
|
Optional[str]
|
Path to config directory (default: project_root/config) |
None
|
strict
|
bool
|
If True, fail on validation errors |
True
|
Source code in src/onion_peeler/settings/loader.py
find_site_for_url(url)
¶
Find site ID by matching URL against domains.
Source code in src/onion_peeler/settings/loader.py
list_sites()
¶
List all available site IDs.
Source code in src/onion_peeler/settings/loader.py
load_all_sites()
¶
Load all site configurations.
Source code in src/onion_peeler/settings/loader.py
load_global_config()
¶
Load global configuration.
Loads from: 1. base.toml [scrapy] section 2. Environment variables (ONION_PEELER__*)
Returns:
| Type | Description |
|---|---|
GlobalConfig
|
Validated GlobalConfig instance |
Source code in src/onion_peeler/settings/loader.py
load_site_config(site_id=None)
¶
Load site-specific configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
site_id
|
Optional[str]
|
Site identifier (filename without .toml) If None, uses ONION_PEELER_SITE env var |
None
|
Returns:
| Type | Description |
|---|---|
SiteConfig
|
Validated SiteConfig instance |
Source code in src/onion_peeler/settings/loader.py
get_loader()
¶
load_global_config()
¶
load_item_selectors(item_type, site_id=None)
¶
Load selectors for an item type from site config.
Source code in src/onion_peeler/settings/loader.py
load_selector(item_type, field_name, site_id=None)
¶
Load a single selector field for a site and item type.