eftoolkit.config¶
Configuration utilities for JSON loading and logging setup.
Functions¶
load_json_config¶
load_json_config
¶
Load a JSON config file, stripping JSONC-style comments.
Supports: - Standard JSON files - JSONC files with // single-line comments - JSONC files with / / block comments
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Path to the JSON/JSONC file |
required |
strip_comment_keys
|
bool
|
If True, also remove keys starting with '_comment' from the loaded config using remove_comments(). Default: False. |
False
|
Returns:
| Type | Description |
|---|---|
dict
|
Parsed JSON as a dictionary |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If the file does not exist |
JSONDecodeError
|
If the content is not valid JSON after stripping comments |
Example
Load config with _comment keys stripped¶
config = load_json_config('config.json', strip_comment_keys=True)
Source code in eftoolkit/config/utils.py
setup_logging¶
setup_logging
¶
setup_logging(
level: int = INFO,
format: str | None = None,
date_format: str | None = None,
) -> None
Configure the root logger with the specified level and format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
level
|
int
|
Logging level (default: logging.INFO) |
INFO
|
format
|
str | None
|
Log format string (default: '%(asctime)s - %(name)s - %(levelname)s - %(message)s') |
None
|
date_format
|
str | None
|
Date/time format string for %(asctime)s (default: None, uses logging module default of '%Y-%m-%d %H:%M:%S,uuu') |
None
|