cmeta.core module
СMeta core class and functions
cMeta author and developer: (C) 2025-2026 Grigori Fursin
See the cMeta COPYRIGHT and LICENSE files in the project root for details.
Classes
- class cmeta.core.CMeta(home: str | None = None, debug: bool | None = None, fail_on_error: bool | None = None, log_level: str | None = None, log_file: str | None = None, log_format: str | None = None, pause_if_error: bool | None = None, package_allow_install: bool | None = True, package_timeout: float | None = None, print_host_info: bool | None = False)[source]
Bases:
objectA common meta system to manage and reuse common artifacts and their automations.
- __init__(home: str | None = None, debug: bool | None = None, fail_on_error: bool | None = None, log_level: str | None = None, log_file: str | None = None, log_format: str | None = None, pause_if_error: bool | None = None, package_allow_install: bool | None = True, package_timeout: float | None = None, print_host_info: bool | None = False)[source]
Initialize CMeta with repositories
- Parameters:
home_path – Path to cmeta-repos.json config file. If None, will search in: 1. CMETA_HOME environment variable. If None or “”, will search in: 2. $HOME/CMETA directory
debug – If True, sets log_level to “DEBUG” (overrides log_level parameter). If False, logging behavior depends on log_level parameter.
fail_on_error – If True, raise error instead of returning dictionary with error
log_level – Logging level as string (case-insensitive). Accepted values: “DEBUG”, “INFO”, “WARNING”, “ERROR”, “CRITICAL” If None or empty string, logging is disabled.
log_file – Path to log file. If provided and not empty, logs will be written to this file. If None or empty string, logs will be written to console.
- Returns:
This is a constructor that initializes the CMeta instance.
- Return type:
None
- Raises:
FileExistsError – If there’s a race condition when creating the home directory.
OSError – If there’s an error creating the home directory due to permissions or other OS-level issues.
PermissionError – If the process lacks permissions to create the home directory.
Exception – For any other unexpected errors during directory creation or initialization.
Constants
- cmeta.core.control_params_desc = [{'aliases': ['h'], 'desc': 'Show help', 'key': 'help', 'type': <class 'bool'>}, {'aliases': ['v'], 'desc': 'Show version', 'key': 'version', 'type': <class 'bool'>}, {'desc': 'Reindex all artifacts', 'key': 'reindex', 'type': <class 'bool'>}, {'aliases': ['v'], 'desc': 'Use verbose output', 'key': 'verbose', 'type': <class 'bool'>}, {'desc': 'Category name (taken from the 1st argument from CLI)', 'key': 'category', 'skip_from_help': True, 'types': [<class 'str'>, <class 'dict'>]}, {'desc': 'Command (taken from the 2st argument from CLI)', 'key': 'command', 'skip_from_help': True, 'type': <class 'str'>}, {'desc': 'Force output to console', 'key': 'con', 'space_before': True, 'type': <class 'bool'>}, {'aliases': ['j'], 'desc': 'Print command output as JSON', 'key': 'json', 'type': <class 'bool'>}, {'aliases': ['json-file', 'jf'], 'desc': 'Specify json file to save command output', 'key': 'json_file', 'type': <class 'str'>}, {'desc': 'Call common commands from the base category', 'key': 'base', 'space_before': True, 'type': <class 'bool'>}, {'desc': 'Choose category API version', 'key': 'api', 'type': <class 'int'>}, {'desc': 'Specify path with CMeta repositories', 'key': 'home', 'space_before': True, 'types': [<class 'str'>, <class 'bool'>]}, {'desc': 'Enable debug mode (sets log_level to "DEBUG" and fail_on_error to True)', 'key': 'debug', 'type': <class 'bool'>}, {'aliases': ['fail', 'fail-on-error'], 'desc': 'Raise exception on first error for debugging', 'key': 'fail_on_error', 'type': <class 'bool'>}, {'aliases': ['log-level'], 'desc': 'Set logging level (e.g., debug, info, warning, error)', 'key': 'log_level', 'type': <class 'str'>, 'values': ['DEBUG', 'INFO', 'WARNING', 'WARN', 'ERROR', 'CRITICAL', 'FATAL']}, {'aliases': ['log-file'], 'desc': 'Specify file for logging', 'key': 'log_file', 'type': <class 'str'>}, {'aliases': ['pif'], 'desc': 'Pause before exiting in case of errors', 'key': 'pause_if_error', 'type': <class 'bool'>}]
Built-in mutable sequence.
If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified.