cmeta.category_api_v1 module

CMeta base category class

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.category_api_v1.Category(*args, **kwargs)[source]

Bases: InitCategory

Standard Base Category with artifact management functions

__init__(*args, **kwargs)[source]

Initialize the category base class without artifact management functions.

Parameters:
  • cm – CMeta instance. If None, creates a new one.

  • module_file_path – Path to the category module file. If None, uses base category.

  • logger – Logger instance. If None, uses CMeta’s logger.

test(params: dict)[source]

Test category.

Parameters:

params (dict) – Parameters dictionary.

Returns:

A cMeta dictionary with the following keys:
  • return (int): 0 if success, >0 if error.

Return type:

dict

info_(state: dict, arg1: str | None = None, clip: bool = True, url: bool = False, name: bool = False)[source]

Get artifact info.

Parameters:
  • state (dict) – cMeta state.

  • arg1 (str | None) – Artifact alias or UID.

  • clip (bool) – If True, copy cRef to clipboard.

  • url (bool) – If True, copy URL with detected cRef to the clipboard.

  • name (bool) – If True, copy artifact name to the clipboard

Returns:

A cMeta dictionary with the following keys:
  • return (int): 0 if success, >0 if error.

  • error (str): Error message if return > 0.

  • artifacts (list): List of matched artifacts.

Return type:

dict

find_(state: dict, arg1: str | None = None, tags: str | None = None, sort: bool | None = None, add_index_file: bool = False, skip_uids: bool = False)[source]

Find artifacts.

Parameters:
  • state (dict) – cMeta state.

  • arg1 (str | None) – Artifact alias or UID.

  • tags (str | list | None) – Comma-separated string or iterable of tags to match.

  • sort (bool) – Sort by path (True by default).

  • add_index_file (bool) – Add index file information.

  • skip_uids (bool) – Skip UIDs when using wildcards.

Returns:

A cMeta dictionary with the following keys:
  • return (int): 0 if success, >0 if error.

  • error (str): Error message if return > 0.

  • artifacts (list): List of matched artifacts.

Return type:

dict

tags_(state: dict, arg1: str | None = None, tags: str | None = None, sort: bool = False)[source]

Find unique tags in artifacts.

Parameters:
  • state (dict) – cMeta state.

  • arg1 (str | None) – Artifact alias or UID.

  • tags (str | list | None) – Comma-separated string or iterable of tags to match.

Returns:

A cMeta dictionary with the following keys:
  • return (int): 0 if success, >0 if error.

  • error (str): Error message if return > 0.

  • artifacts (list): List of matched artifacts.

Return type:

dict

update_(state: dict, arg1: str | None = None, tags: str | None = None, sort: bool = True, skip_uids: bool = False, meta: dict = {}, new_tags: str | None = None, replace_lists: bool = False, replace: bool = False, ignore_errors: bool = False, create: bool = False, create_params: dict = {}, update_category: bool = False)[source]

Update artifact(s).

state (dict): cMeta state. arg1 (str | None): cMeta artifact(s) with wildcards. tags (str | list | None): Prune artifacts by tags. sort (bool): Sort artifacts by alias and UID when updating in batch. skip_uids (bool): Skip UIDs when using wildcards. meta (dict): Meta dictionary to merge recursively with existing artifact. new_tags (str | list | None): Add more tags. replace_lists (bool): Replace lists during merging. replace (bool): Replace existing meta dictionary entirely. ignore_errors (bool): Ignore errors when updating multiple artifacts. create (bool): If artifact doesn’t exist attempt to create. create_params (dict): Pass params to create function. update_category (bool): Allow category update in meta

Returns:

A cMeta dictionary with the following keys:
  • return (int): 0 if success, >0 if error.

  • error (str): Error message if return > 0.

  • artifacts (list): All matched artifacts.

  • updated_artifacts (list): Updated artifacts.

Return type:

dict

list_(state: dict, arg1: str | None = None, tags: str | None = None, sort: bool | None = None, skip_uids: bool = False)[source]

List artifact names.

Parameters:
  • state (dict) – cMeta state.

  • arg1 (str | None) – Artifact alias or UID.

  • tags (str | list | None) – Optional tag filter.

  • sort (bool) – Sort by alias or UID.

  • skip_uids (bool) – Skip UIDs when using wildcards.

Returns:

A cMeta dictionary with the following keys:
  • return (int): 0 if success, >0 if error.

  • error (str): Error message if return > 0.

  • artifacts (list): List of matched artifacts.

Return type:

dict

read_(state: dict, arg1: str | None = None, tags: str | None = None, extra: bool = False, skip_uids: bool = False, yaml: bool = False, load_files=[])[source]

Read artifact meta.

Parameters:
  • state (dict) – cMeta state.

  • arg1 (str | None) – Artifact alias or UID.

  • tags (str | list | None) – Optional tag filter.

  • extra (bool) – Show extra info.

  • skip_uids (bool) – Skip UIDs when using wildcards.

  • yaml (bool) – Output as YAML instead of JSON.

Returns:

A cMeta dictionary with the following keys:
  • return (int): 0 if success, >0 if error.

  • error (str): Error message if return > 0.

  • artifact (dict): Matched artifact.

  • cmeta (dict): Artifact metadata.

Return type:

dict

delete_(state: dict, arg1: str | None = None, tags: str | None = None, sort: bool = True, force: bool = False, f: bool = False, skip_uids: bool = False, ignore_errors: bool = False, print_time: bool = False)[source]

Delete and unindex artifact(s).

Parameters:
  • state (dict) – cMeta state.

  • arg1 (str | None) – Artifact alias or UID.

  • tags (str | list | None) – Optional tag filter.

  • sort (bool) – Sort artifacts by alias and UID.

  • force (bool) – Force deletion without confirmation.

  • f (bool) – Shorthand for force.

  • skip_uids (bool) – Skip UIDs when using wildcards.

  • ignore_errors (bool) – Ignore errors when deleting multiple artifacts.

  • print_time (bool) – Print time per deletion.

Returns:

A cMeta dictionary with the following keys:
  • return (int): 0 if success, >0 if error.

  • error (str): Error message if return > 0.

  • artifacts (list): All matched artifacts.

  • deleted_artifacts (list): Deleted artifacts.

Return type:

dict

create_(state: dict, arg1: str | None = None, tags: str | None = None, meta: dict = {}, yaml: bool = False, virtual: bool = False, path: str | None = None)[source]

Create and index an artifact.

Parameters:
  • state (dict) – cMeta state.

  • arg1 (str | None) – Artifact alias or UID.

  • tags (str | list | None) – Tags to add to the artifact.

  • meta (dict) – Initial metadata dictionary.

  • yaml (bool) – Save metadata as YAML instead of JSON.

  • virtual (bool) – Virtual artifact created only in index (such as repo).

  • path (str | None) – Use this path for artifact (useful for virtual artifacts such as repo).

Returns:

A cMeta dictionary with the following keys:
  • return (int): 0 if success, >0 if error.

  • error (str): Error message if return > 0.

  • path (str): Path to the created artifact.

  • meta (dict): Artifact metadata.

Return type:

dict

move_(state: dict, arg1: str, arg2: str, tags: str | None = None, sort: bool = True, skip_uids: bool = False, ignore_errors: bool = False, copy: bool = False)[source]

Rename and/or move artifact(s).

Parameters:
  • state (dict) – cMeta state.

  • arg1 (str) – cMeta artifact(s) with wildcards to be renamed or moved.

  • arg2 (str) – New cMeta artifact name and/or new repository.

  • tags (str | list | None) – Prune source artifacts by tags.

  • sort (bool) – Sort artifacts by alias and UID when updating in batch.

  • skip_uids (bool) – Skip UIDs when using wildcards.

  • ignore_errors (bool) – Ignore errors when updating multiple artifacts.

  • copy (bool) – If True, copy artifact instead of moving.

Returns:

A cMeta dictionary with the following keys:
  • return (int): 0 if success, >0 if error.

  • error (str): Error message if return > 0.

  • artifacts (list): All matched artifacts.

  • updated_artifacts (list): Updated artifacts.

Return type:

dict

copy__(params: dict)[source]

Copy artifact(s).

@base.move_(**params, copy=True)

Parameters:

params (dict) – cMeta params.

Returns:

A cMeta dictionary (see move_ for details).

Return type:

dict

get_(state: dict, arg1: str | None = None, tags: str | None = None, skip_uids: bool = False, yaml: bool = False, meta: dict = {}, virtual: bool = False, path: str | None = None, show_path: bool = False, load_files=[])[source]

Get artifact meta. Read if exists, create and read if doesn’t exist.

Parameters:
  • state (dict) – cMeta state.

  • arg1 (str | None) – Artifact alias or UID.

  • tags (str | list | None) – Tags to add to the artifact (used during creation).

  • skip_uids (bool) – Skip UIDs when using wildcards.

  • yaml (bool) – Save/output metadata as YAML instead of JSON.

  • meta (dict) – Initial metadata dictionary (used during creation).

  • virtual (bool) – Virtual artifact created only in index (used during creation).

  • path (str | None) – Use this path for artifact (used during creation).

  • show_path (bool) – Print path instead of meta

Returns:

A cMeta dictionary with the following keys:
  • return (int): 0 if success, >0 if error.

  • error (str): Error message if return > 0.

  • artifact (dict): Matched artifact.

  • cmeta (dict): Artifact metadata.

  • created (bool): True if artifact was created, False if it already existed.

Return type:

dict

set_(state: dict, arg1: str | None = None, tags: str | None = None, skip_uids: bool = False, yaml: bool = False, meta: dict = {}, virtual: bool = False, path: str | None = None, show_path: bool = False)[source]

Set artifact meta. Update and read if exists, create and read if doesn’t exist.

Parameters:
  • state (dict) – cMeta state.

  • arg1 (str | None) – Artifact alias or UID.

  • tags (str | list | None) – Tags to add to the artifact (used during creation).

  • skip_uids (bool) – Skip UIDs when using wildcards.

  • yaml (bool) – Save/output metadata as YAML instead of JSON.

  • meta (dict) – Initial metadata dictionary (used during creation).

  • virtual (bool) – Virtual artifact created only in index (used during creation).

  • path (str | None) – Use this path for artifact (used during creation).

  • show_path (bool) – Print path instead of meta

Returns:

A cMeta dictionary with the following keys:
  • return (int): 0 if success, >0 if error.

  • error (str): Error message if return > 0.

  • artifact (dict): Matched artifact.

  • cmeta (dict): Artifact metadata.

  • created (bool): True if artifact was created, False if it already existed.

Return type:

dict