cMeta open-source categories, artifacts and automations

[ Back to projects ]
[ Back ]

One category from internal.

← All categories

utils

Miscellaneous helper commands exposed through the uniform interface.

Comes from
(internal)
License
Apache-2.0
UID
234ce5e3262e4d52
Tags
category utils
Copyright
2025-2026 Grigori Fursin and cTuning Labs. See the cMeta COPYRIGHT and LICENSE files for details.

Its own commands

CommandWhat it does
access_ctuning_server
v1.py:1456-1523
Access cTuning server
signature

    def access_ctuning_server_(
        self,
        ctx,  # Execution context dictionary with category, command, and control data.
        query = {},  # Input parameter used by this function.
        headers = {},  # Input parameter used by this function.
        timeout = 30,  # Timeout value in seconds.
        url = None,  # Input parameter used by this function.
        api_key = None,  # Input parameter used by this function.
        files = {},  # Input parameter used by this function.
    ):

        """
            Access cTuning server

            Args:
                ctx: Execution context dictionary with category, command, and control data.
                query: Input parameter used by this function.
                headers: Input parameter used by this function.
                timeout: Timeout value in seconds.
                url: Input parameter used by this function.
                api_key: Input parameter used by this function.
                files: Input parameter used by this function.
            Returns:
                dict: Operation result.
            Raises:
                Exception: Propagated runtime errors, if any.
        """
artifacts
v1.py:1228-1348
Analyze all artifacts for all categories
signature

    def artifacts_(
        self,
        ctx,  # Execution context dictionary with category, command, and control data.
        arg1 = None,  # First positional argument from command input.
        arg2 = None,  # Second positional argument from command input.
        skip_categories = None,  # Input parameter used by this function.
        func = None,  # Input parameter used by this function.
        func_params = {},  # Input parameter used by this function.
    ):

        """
            Analyze all artifacts for all categories

            arg1: categories
            arg2: artifacts
            top_num: number of top artifacts to show in rankings (default: 30)
            slow: if False (default), use cached results when artifact hasn't changed; if True, always perform deep analysis

            @base.find_

            Args:
                ctx: Execution context dictionary with category, command, and control data.
                arg1: First positional argument from command input.
                arg2: Second positional argument from command input.
                skip_categories: Input parameter used by this function.
                func: Input parameter used by this function.
                func_params: Input parameter used by this function.
            Returns:
                dict: Operation result.
            Raises:
                Exception: Propagated runtime errors, if any.
        """
convert_old_entries
v1.py:1074-1225
Convert legacy CK/CM/CMX entries in a path (arg1) by merging _cmeta.json or _cmeta.yaml with meta
signature

    def convert_old_entries_(
        self,
        ctx,  # cMeta context.
        arg1 = '.',  # Path to search for entries to convert.
        meta = {},  # Merge this meta with existing _cmeta files.
    ):

        """
            Convert legacy CK/CM/CMX entries in a path (arg1) by merging _cmeta.json or _cmeta.yaml with meta

            Args:
                ctx (dict): cMeta context.
                arg1 (str): Path to search for entries to convert.
                meta (dict): Merge this meta with existing _cmeta files.

            Returns:
                dict: Operation result.
            Raises:
                Exception: Propagated runtime errors, if any.
        """
copy_date_time_iso_to_clipboard
v1.py:755-779
Copy text to clipboard
signature

    def copy_date_time_iso_to_clipboard_(
        self,
        ctx,  # cMeta context object.
        do_not_fail = True,  # Do not fail on error if True.
    ):

        """
            Copy text to clipboard

            Args:
                ctx (dict): cMeta context object.
                arg1 (str): Text to copy to clipboard.
                add_quotes (bool): Add quotes to the text if True.
                do_not_fail (bool): Do not fail on error if True.

            Returns:
                dict: Operation result.
            Raises:
                Exception: Propagated runtime errors, if any.
        """
copy_date_time_to_clipboard
v1.py:728-752
Copy text to clipboard
signature

    def copy_date_time_to_clipboard_(
        self,
        ctx,  # cMeta context object.
        do_not_fail = True,  # Do not fail on error if True.
    ):

        """
            Copy text to clipboard

            Args:
                ctx (dict): cMeta context object.
                arg1 (str): Text to copy to clipboard.
                add_quotes (bool): Add quotes to the text if True.
                do_not_fail (bool): Do not fail on error if True.

            Returns:
                dict: Operation result.
            Raises:
                Exception: Propagated runtime errors, if any.
        """
copy_date_to_clipboard
v1.py:701-725
Copy text to clipboard
signature

    def copy_date_to_clipboard_(
        self,
        ctx,  # cMeta context object.
        do_not_fail = True,  # Do not fail on error if True.
    ):

        """
            Copy text to clipboard

            Args:
                ctx (dict): cMeta context object.
                arg1 (str): Text to copy to clipboard.
                add_quotes (bool): Add quotes to the text if True.
                do_not_fail (bool): Do not fail on error if True.

            Returns:
                dict: Operation result.
            Raises:
                Exception: Propagated runtime errors, if any.
        """
copy_text_to_clipboard
v1.py:676-698
Copy text to clipboard
signature

    def copy_text_to_clipboard_(
        self,
        ctx,  # cMeta context object.
        arg1 = '',  # Text to copy to clipboard.
        add_quotes = False,  # Add quotes to the text if True.
        do_not_fail = True,  # Do not fail on error if True.
    ):

        """
            Copy text to clipboard

            Args:
                ctx (dict): cMeta context object.
                arg1 (str): Text to copy to clipboard.
                add_quotes (bool): Add quotes to the text if True.
                do_not_fail (bool): Do not fail on error if True.

            Returns:
                dict: Operation result.
            Raises:
                Exception: Propagated runtime errors, if any.
        """
create_artifact_with_date
v1.py:1352-1451
Create artifact with date
signature

    def create_artifact_with_date(
        self,
        params,  # Input parameters dictionary.
    ):

        """
            Create artifact with date

            @base.create_

            Args:
                params: Input parameters dictionary.
            Returns:
                dict: Operation result.
            Raises:
                Exception: Propagated runtime errors, if any.
        """
detect_category
v1.py:531-602
Detect the cMeta category of the current (or a given) directory
signature

    def detect_category_(
        self,
        ctx,  # cMeta context.
        arg1 = None,  # Directory to inspect. If None, use the current directory.
        fail_if_not_found = False,  # If True, return an error when nothing is detected.
    ):

        """
            Detect the cMeta category of the current (or a given) directory

            Uses the same detection as `cx . <command>`: locate the plugged
            repository that contains the directory, then report the category
            (and the artifact, when standing inside one).

            Prints the category as `alias,UID`, or as just the alias when the
            UID is not known - such as when standing in the category directory
            itself rather than inside one of its artifacts. Prints nothing when
            no category can be detected.

            Detecting nothing is not an error: the command returns 0 with
            `category` set to None, so callers can fall back to a wider search.
            Pass `fail_if_not_found` to turn it into an error instead.

            Args:
                ctx (dict): cMeta context.
                arg1 (str): Directory to inspect. If None, use the current directory.
                fail_if_not_found (bool): If True, return an error when nothing is detected.

            Returns:
                dict: Operation result with `category` (str or None),
                      `category_alias`, `category_uid`, `artifact_name`,
                      `artifact_repo_name` and the inspected `path`.
            Raises:
                Exception: Propagated runtime errors, if any.
        """
detect_repo
v1.py:605-673
Detect the cMeta repository of the current (or a given) directory
signature

    def detect_repo_(
        self,
        ctx,  # cMeta context.
        arg1 = None,  # Directory to inspect. If None, use the current directory.
        fail_if_not_found = False,  # If True, return an error when nothing is detected.
    ):

        """
            Detect the cMeta repository of the current (or a given) directory

            The counterpart of `detect_category`, using the same detection as
            `cx . <command>`: find which plugged repository contains the
            directory.

            Prints the repository as `alias,UID`, or as just the alias or UID
            when only one of them is known. Prints nothing when the directory
            is outside every plugged repository.

            Detecting nothing is not an error: the command returns 0 with
            `repo` set to None, so callers can fall back to a wider search.
            Pass `fail_if_not_found` to turn it into an error instead.

            Args:
                ctx (dict): cMeta context.
                arg1 (str): Directory to inspect. If None, use the current directory.
                fail_if_not_found (bool): If True, return an error when nothing is detected.

            Returns:
                dict: Operation result with `repo` (str or None), `repo_alias`,
                      `repo_uid`, `artifact_path` (the path relative to the
                      repository root) and the inspected `path`.
            Raises:
                Exception: Propagated runtime errors, if any.
        """
find_by_cid
v1.py:138-371
Find artifacts by standard CID
signature

    def find_by_cid_(
        self,
        ctx,  # cMeta context.
        arg1 = None,  # Standard CID.
        tags = None,  # Comma-separated string or iterable of tags to match ("-tag" excludes).
        far = False,  # If True, open FAR manager in found artifact path.
        web = False,  # If True, decode web-style `cmeta:///?` CID input.
        ask = False,  # If True, ask for CID in console.
        skip_non_indexed = False,  # If True, skip non-indexed repositories.
        match = None,  # Value for match.
        match_empty_version = False,  # Value for match empty version.
        match_empty_values = False,  # Match when queried values or keys are empty.
        all_tags = None,  # Value for all tags.
        smart_match = None,  # Comma-separated values - keep artifacts holding any of them under any meta key.
        search_text = None,  # Space-separated texts - keep artifacts whose files contain any of them.
        search_files = None,  # Comma-separated globs naming those files (default "*info*.md"; "**" recurses).
        search_file_names = None,  # Space-separated strings that must ALL appear in a file name (recursive).
        after_date = None,  # Keep artifacts dated on or after this (ISO or YYYY[MM[DD[-HHMM]]]).
        before_date = None,  # Keep artifacts dated on or before this (same formats).
    ):

        """
            Find artifacts by standard CID

            Args:
                ctx (dict): cMeta context.
                arg1 (str): Standard CID.
                tags (str): Comma-separated string or iterable of tags to match ("-tag" excludes).
                far (bool): If True, open FAR manager in found artifact path.
                web (bool): If True, decode web-style `cmeta:///?` CID input.
                ask (bool): If True, ask for CID in console.
                skip_non_indexed (bool): If True, skip non-indexed repositories.
                match (dict): Value for match.
                match_empty_version (bool): Value for match empty version.
                match_empty_values (bool): Match when queried values or keys are empty.
                all_tags (str): Value for all tags.
                smart_match (str | list): Comma-separated values - keep artifacts holding
                                          any of them under any meta key.
                search_text (str | list): Space-separated texts - keep artifacts whose
                                          files contain any of them.
                search_files (str | list): Comma-separated globs naming those files
                                           (default "*info*.md"; "**" recurses).
                search_file_names (str | list): Space-separated strings that must ALL
                                               appear in a file name. Always recursive,
                                               and replaces search_files when given.
                after_date (str): Keep artifacts dated on or after this. Full ISO, or
                                  YYYY / YYYYMM / YYYYMMDD / YYYYMMDD-HHMM and the
                                  dashed variants. The date is taken from the artifact
                                  name when it starts with one, else from
                                  last_update_timestamp, else from creation_timestamp.
                before_date (str): Keep artifacts dated on or before this, same formats.

            Returns:
                dict: Operation result. When search_text or search_file_names was
                      given, "files" holds the full paths of every matching file
                      and those are printed instead of the artifact directories.
            Raises:
                Exception: Propagated runtime errors, if any.
        """
get_datetime
v1.py:1587-1619
Args:
signature

    def get_datetime_(
        self,
        ctx,  # Execution context dictionary with category, command, and control data.
    ):

        """
            Args:
                ctx: Execution context dictionary with category, command, and control data.
            Returns:
                dict: Operation result.
            Raises:
                Exception: Propagated runtime errors, if any.
        """
json2pickle
v1.py:955-1007
Convert JSON file to pickle file
signature

    def json2pickle_(
        self,
        ctx,  # cMeta context.
        arg1,  # JSON file.
        arg2 = None,  # Pickle file (if not specified, use base of json file with .pkl).
    ):

        """
            Convert JSON file to pickle file

            Args:
                ctx (dict): cMeta context.
                arg1 (str): JSON file.
                arg2 (str): Pickle file (if not specified, use base of json file with .pkl).

            Returns:
                dict: Operation result.
            Raises:
                Exception: Propagated runtime errors, if any.
        """
json2yaml
v1.py:782-826
Convert JSON file to YAML file
signature

    def json2yaml_(
        self,
        ctx,  # cMeta context.
        arg1,  # Input JSON file.
        arg2 = None,  # Output YAML file (if None, use {input file without ext}.yaml).
        force = False,  # If True and output file exists, overwrite it.
        f = False,  # If True and output file exists, overwrite it.
        sort_keys = False,  # Sort keys in output if True.
    ):

        """
            Convert JSON file to YAML file

            Args:
                ctx (dict): cMeta context.
                arg1 (str): Input JSON file.
                arg2 (str): Output YAML file (if None, use {input file without ext}.yaml).
                force (bool): If True and output file exists, overwrite it.
                f (bool): If True and output file exists, overwrite it.
                sort_keys (bool): Sort keys in output if True.

            Returns:
                dict: Operation result.
            Raises:
                Exception: Propagated runtime errors, if any.
        """
pickle2json
v1.py:897-952
Convert pickle file to JSON file
signature

    def pickle2json_(
        self,
        ctx,  # cMeta context.
        arg1,  # Pickle file.
        arg2 = None,  # JSON file (if not specified, use base of pickle file with .json).
        sort_keys = False,  # Sort keys in output if True.
    ):

        """
            Convert pickle file to JSON file

            Args:
                ctx (dict): cMeta context.
                arg1 (str): Pickle file.
                arg2 (str): JSON file (if not specified, use base of pickle file with .json).
                sort_keys (bool): Sort keys in output if True.

            Returns:
                dict: Operation result.
            Raises:
                Exception: Propagated runtime errors, if any.
        """
pkl2json
v1.py:878-893
@self.pickle2json_
signature

    def pkl2json(
        self,
        params,  # Input parameters dictionary.
    ):

        """
            @self.pickle2json_

            Args:
                params: Input parameters dictionary.
            Returns:
                dict: Operation result.
            Raises:
                Exception: Propagated runtime errors, if any.
        """
select_artifact
v1.py:1569-1584
Args:
signature

    def select_artifact(
        self,
        params,  # Input parameters dictionary.
    ):

        """
            Args:
                params: Input parameters dictionary.
            Returns:
                dict: Operation result.
            Raises:
                Exception: Propagated runtime errors, if any.
        """
smart_find_by_cid
v1.py:374-479
Find artifacts by wrapped CID
signature

    def smart_find_by_cid_(
        self,
        ctx,  # cMeta context.
        arg1 = None,  # CID that can be wrapped with some text.
        far = False,  # If True, open FAR in found artifact.
        web = False,  # If True, remove cmeta:///? from CID (web request).
        ask = False,  # If True, ask for CID in console.
        cid = None,  # Direct CID to use.
        tags = None,  # Comma-separated string or iterable of tags to match ("-tag" excludes).
        match = None,  # Value for match.
        match_empty_version = False,  # Value for match empty version.
        match_empty_values = False,  # Match when queried values or keys are empty.
        all_tags = None,  # Value for all tags.
        smart_match = None,  # Comma-separated values - keep artifacts holding any of them under any meta key.
        search_text = None,  # Space-separated texts - keep artifacts whose files contain any of them.
        search_files = None,  # Comma-separated globs naming those files (default "*info*.md"; "**" recurses).
        search_file_names = None,  # Space-separated strings that must ALL appear in a file name (recursive).
        after_date = None,  # Keep artifacts dated on or after this (ISO or YYYY[MM[DD[-HHMM]]]).
        before_date = None,  # Keep artifacts dated on or before this (same formats).
    ):

        """
            Find artifacts by wrapped CID

            Args:
                ctx (dict): cMeta context.
                arg1 (str): CID that can be wrapped with some text.
                far (bool): If True, open FAR in found artifact.
                web (bool): If True, remove cmeta:///? from CID (web request).
                ask (bool): If True, ask for CID in console.
                cid (str): Direct CID to use.
                tags (str): Comma-separated string or iterable of tags to match ("-tag" excludes).
                match (dict): Value for match.
                match_empty_version (bool): Value for match empty version.
                match_empty_values (bool): Match when queried values or keys are empty.
                all_tags (str): Value for all tags.
                smart_match (str | list): Comma-separated values - keep artifacts holding
                                          any of them under any meta key.
                search_text (str | list): Space-separated texts - keep artifacts whose
                                          files contain any of them.
                search_files (str | list): Comma-separated globs naming those files
                                           (default "*info*.md"; "**" recurses).
                search_file_names (str | list): Space-separated strings that must ALL
                                               appear in a file name. Always recursive,
                                               and replaces search_files when given.
                after_date (str): Keep artifacts dated on or after this. Full ISO, or
                                  YYYY / YYYYMM / YYYYMMDD / YYYYMMDD-HHMM and the
                                  dashed variants. The date is taken from the artifact
                                  name when it starts with one, else from
                                  last_update_timestamp, else from creation_timestamp.
                before_date (str): Keep artifacts dated on or before this, same formats.

            Returns:
                dict: Operation result.
            Raises:
                Exception: Propagated runtime errors, if any.
        """
test
v1.py:44-67
test function.
signature

    def test(
        self,
        params,  # Input dictionary used by this function.
    ):


        """
        test function.

        Args:
            params: Input dictionary used by this function.

        Returns:
            dict: Operation result.

        Raises:
            Exception: Propagated runtime errors, if any.
        """
test_public_server
v1.py:1543-1566
@self.access_ctuning_server_
signature

    def test_public_server(
        self,
        params,  # Input parameters dictionary.
    ):

        """
            @self.access_ctuning_server_

            Args:
                params: Input parameters dictionary.
            Returns:
                dict: Operation result.
            Raises:
                Exception: Propagated runtime errors, if any.
        """
uid
v1.py:70-100
Generate a 16-character cMeta UID.
signature

    def uid_(
        self,
        ctx,  # cMeta context object.
        clipboard = True,
    ):

        """
            Generate a 16-character cMeta UID.

            Args:
                ctx (dict): cMeta context object.
                clipboard (bool): If True, copy the generated UID to the clipboard.

            Returns:
                dict: Operation result.
            Raises:
                Exception: Propagated runtime errors, if any.
        """
utf8sig_to_utf8
v1.py:1010-1070
Convert UTF-8 with BOM (utf-8-sig) file to standard UTF-8
signature

    def utf8sig_to_utf8_(
        self,
        ctx,  # cMeta context.
        arg1,  # Input file (UTF-8 with BOM).
        arg2 = None,  # Output file (if None, overwrites input file and creates .bak backup).
    ):

        """
            Convert UTF-8 with BOM (utf-8-sig) file to standard UTF-8

            Args:
                ctx (dict): cMeta context.
                arg1 (str): Input file (UTF-8 with BOM).
                arg2 (str): Output file (if None, overwrites input file and creates .bak backup).

            Returns:
                dict: Operation result.
            Raises:
                Exception: Propagated runtime errors, if any.
        """
uuid
v1.py:103-135
Generate a UUID4 string.
signature

    def uuid_(
        self,
        ctx,  # cMeta context
        clipboard = True,
    ):

        """
            Generate a UUID4 string.

            Args:
                ctx (dict): cMeta context.
                clipboard (bool): If True, copy the generated UUID to the clipboard.

            Returns:
                dict: Operation result.
            Raises:
                Exception: Propagated runtime errors, if any.
        """
x
v1.py:1526-1540
@self.access_ctuning_server_
signature

    def x(
        self,
        params,  # Input parameters dictionary.
    ):

        """
            @self.access_ctuning_server_

            Args:
                params: Input parameters dictionary.
            Returns:
                dict: Operation result.
            Raises:
                Exception: Propagated runtime errors, if any.
        """
yaml2json
v1.py:830-874
Convert YAML file to JSON file
signature

    def yaml2json_(
        self,
        ctx,  # cMeta context.
        arg1,  # Input YAML file.
        arg2 = None,  # Output JSON file (if None, use {input file without ext}.json).
        force = False,  # If True and output file exists, overwrite it.
        f = False,  # If True and output file exists, overwrite it.
        sort_keys = False,  # Sort keys in output if True.
    ):

        """
            Convert YAML file to JSON file

            Args:
                ctx (dict): cMeta context.
                arg1 (str): Input YAML file.
                arg2 (str): Output JSON file (if None, use {input file without ext}.json).
                force (bool): If True and output file exists, overwrite it.
                f (bool): If True and output file exists, overwrite it.
                sort_keys (bool): Sort keys in output if True.

            Returns:
                dict: Operation result.
            Raises:
                Exception: Propagated runtime errors, if any.
        """

How to use it

cx utils access_ctuning_server
cx utils                     # list every command with its help
from cmeta import CMeta
cm = CMeta()
r = cm.access({'category': 'utils,234ce5e3262e4d52', 'command': 'access_ctuning_server'})

Artifacts

The open-source repositories ship no utils artifacts - this category holds what you and your runs create.

cx utils list

Depends on

Uses categories: category, config

Source: utils on GitHub · its API

Read live from the cMeta index of this server - the same data cx category list shows you locally.