Skip to content

jam.utils.config_maker

config_maker

Functions:

Name Description
__config_maker__

Base config masker.

__module_loader__

Loader custom modules from config.

__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

__module_loader__

__module_loader__(path: str) -> Callable

Loader custom modules from config.

Parameters:

Name Type Description Default
path str

Path to module. For example: my_app.classes.SomeClass

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.