cmeta.repos module
cMeta repositories manager
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.repos.Repos(cfg: Dict[str, Any], home_path: Path, index_path: Path, repos_config_path: Path, logger: Logger | None = None, index_extension: str = '.pkl', fail_on_error: bool = False)[source]
Bases:
objectcMeta repositories manager.
- __init__(cfg: Dict[str, Any], home_path: Path, index_path: Path, repos_config_path: Path, logger: Logger | None = None, index_extension: str = '.pkl', fail_on_error: bool = False)[source]
Initialize Repos manager.
- Parameters:
cfg (Dict[str, Any]) – Configuration dictionary.
home_path (Path) – Path to repositories directory.
index_path (Path) – Path to index directory.
repos_config_path (Path) – Path to repositories config file.
logger (logging.Logger | None) – Logger instance (optional).
index_extension (str) – Index file extension.
fail_on_error (bool) – If True, raise exception on error.
- init(con: bool = False, verbose: bool = False)[source]
Initialize repositories and index if running for the first time.
Creates repos directory, local repository, and triggers reindexing if needed.
- Parameters:
con (bool) – Console mode flag (for compatibility).
verbose (bool) – Enable verbose output (for compatibility).
- Returns:
Dictionary with ‘return’: 0 on success, or ‘return’ > 0 and ‘error’ on failure.
- Return type:
dict
- remove_from_index(index_file, artifact_uid, artifact_alias_lowercase)[source]
Remove an artifact from the repository index.
- Parameters:
index_file – Path to index file.
artifact_uid – UID of artifact to remove.
artifact_alias_lowercase – Lowercase alias of artifact to remove from alias index.
- Returns:
Dictionary with ‘return’: 0 on success, or ‘return’ > 0 and ‘error’ on failure.
- Return type:
dict
- find_in_index(category_alias, category_uid, artifact_alias=None, artifact_uid=None, repos=[], only_uids=False, add_index_file=False, skip_uids=False)[source]
Find artifacts in the repository index.
- Parameters:
category_alias – Lowercase category alias.
category_uid – Category UID.
artifact_alias – Artifact alias to search for.
artifact_uid – Artifact UID to search for.
repos – List of repository names to search in.
only_uids – If True, return only UIDs without full metadata.
add_index_file – If True, include index_file path in result.
skip_uids – If True, skip UID validation.
- Returns:
- Dictionary with ‘return’: 0 and ‘lst’ containing found artifacts,
or ‘return’ > 0 and ‘error’ on failure.
- Return type:
dict
- find_in_file_system(category_meta, category_alias, category_uid, artifact_alias=None, artifact_uid=None, repo_uids=[])[source]
Find artifacts by scanning directories instead of using index. Used for categories with no_index flag.
- Parameters:
category_alias – Category alias (lowercase)
category_uid – Category UID
artifact_alias – Optional artifact alias (supports wildcards)
artifact_uid – Optional artifact UID
- Returns:
{‘return’: 0, ‘artifacts’: […]} or error
- Return type:
dict
- find(cmeta_ref, add_index_file=False, tags=None, skip_uids=False, skip_non_indexed=False)[source]
Find artifacts by cMeta reference.
- Parameters:
cmeta_ref – cMeta reference string or parsed dictionary.
add_index_file – If True, include index_file path in result.
tags – Optional tags to filter results.
skip_uids – If True, skip UID validation.
- Returns:
- Dictionary with ‘return’: 0 and ‘artifacts’ list on success,
or ‘return’ > 0 and ‘error’ on failure.
- Return type:
dict
- reindex(con=False, verbose=False)[source]
Clean index and reindex all repositories.
Removes existing index files and rebuilds them by scanning all repositories.
- Parameters:
con – If True, print console messages during reindexing.
verbose – If True, print detailed progress information.
- Returns:
Dictionary with ‘return’: 0 on success, or ‘return’ > 0 and ‘error’ on failure.
- Return type:
dict