profiles
profiles
¶
Allowlist profile loading and composition.
Finds, reads, and merges .txt allowlist profiles from user and
bundled directories. User profiles override bundled ones with the
same name, so site-specific customisation works without forking.
ProfileLoader(*, user_dir, bundled_dir=None)
¶
Loads and composes .txt allowlist profiles.
Searches user profiles first (overriding bundled), then falls back to the bundled profiles shipped with the package.
Create a profile loader.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_dir
|
Path
|
User profiles directory (overrides bundled). |
required |
bundled_dir
|
Path | None
|
Bundled profiles directory (auto-detected if None). |
None
|
Source code in src/terok_shield/lib/profiles.py
load_profile(name)
¶
Load a profile by name and return its entries.
User profiles take precedence over bundled profiles.
Raises:
| Type | Description |
|---|---|
ValueError
|
If the name contains path separators or traversal. |
FileNotFoundError
|
If the profile does not exist. |
Source code in src/terok_shield/lib/profiles.py
compose_profiles(names)
¶
Load and merge multiple profiles, deduplicating entries.
Preserves insertion order (first occurrence wins).
Raises:
| Type | Description |
|---|---|
ValueError
|
If any name contains path separators or traversal. |
FileNotFoundError
|
If any named profile does not exist. |
Source code in src/terok_shield/lib/profiles.py
list_profiles()
¶
List available profile names (bundled + user, deduplicated).