jam.utils.config_maker¶
config_maker
¶
Functions:
| Name | Description |
|---|---|
__apply_jwt_config_migration__ |
Backward compatibility: copy jam.jwt -> jam.jose.jwt with deprecation warning. |
__config_maker__ |
Base config masker. |
__key_loader__ |
Loads a key from file, if |
__module_loader__ |
Loader custom modules from config. |
__apply_jwt_config_migration__
¶
__apply_jwt_config_migration__(config: dict) -> dict
Backward compatibility: copy jam.jwt -> jam.jose.jwt with deprecation warning.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
dict
|
Parsed configuration dict |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
Updated config with migration applied |
__config_maker__
¶
__config_maker__(
config: str | dict[str, Any],
pointer: str = GENERIC_POINTER,
) -> dict[str, Any]
Base config masker.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
str | dict[str, Any
|
Config dict or file path |
required |
pointer
|
str
|
Pointer to config read |
GENERIC_POINTER
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
dict[str, Any]: Parsed config |
__json_config_parser
¶
__json_config_parser(
path: str,
encoder: BaseEncoder | type[BaseEncoder] = JsonEncoder,
) -> dict[str, Any]
JSON config parser with env substitution.
Supports: - ${VAR} - environment variable (required) - ${VAR:-default} - environment variable with default value - $VAR - short form (required)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Path to JSON file |
required |
encoder
|
BaseEncoder | type[BaseEncoder]
|
Encoder to use for parsing |
JsonEncoder
|
Raises:
| Type | Description |
|---|---|
JamConfigurationError
|
If file not found or invalid JSON or required env var not set |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
dict[str, Any]: Parsed config with environment variable substitution |
__key_loader__
¶
__key_loader__(key: str) -> str
Loads a key from file, if key is a path to a file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Key to load. If it is a path to a file, the file will be loaded. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Loaded key or original key if not a file path. |
__module_loader__
¶
__module_loader__(path: str) -> Callable
Loader custom modules from config.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Path to module. For example: |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If path not str |
Returns:
| Type | Description |
|---|---|
Callable
|
Callable |
__toml_config_parser
¶
__toml_config_parser(
path: str = "pyproject.toml",
pointer: str = GENERIC_POINTER,
) -> dict[str, Any]
Private method for parsing TOML config with env substitution.
Supports: - ${VAR} - environment variable (required) - ${VAR:-default} - environment variable with default value - $VAR - short form (required)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Path to config.toml |
'pyproject.toml'
|
pointer
|
str
|
Pointer to config read |
GENERIC_POINTER
|
Raises:
| Type | Description |
|---|---|
JamConfigurationError
|
If file not found or invalid TOML file or required env var not set |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dict with config param |
__yaml_config_parser
¶
__yaml_config_parser(
path: str, pointer: str = GENERIC_POINTER
) -> dict[str, Any]
Private method for parsing YML config with env substitution.
Supports: - ${VAR} - environment variable (required) - ${VAR:-default} - environment variable with default value - $VAR - short form (required)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Path to config.yml |
required |
pointer
|
str
|
Pointer to config section to read. |
GENERIC_POINTER
|
Raises:
| Type | Description |
|---|---|
JamConfigurationError
|
If pyyaml not installed, file not found, or invalid YAML |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
dict[str, Any]: Parsed YAML section with environment variable substitution. |