Skip to content

utils

Utils.

attempt_as_posix_rootless_path(path, project_name)

Format provided path to posix rootless if possible.

Source code in client/ayon_workflow/utils.py
89
90
91
92
93
94
95
def attempt_as_posix_rootless_path(path: str, project_name: str) -> str:
    """ Format provided path to posix rootless if possible.
    """
    posix_path = Path(path).as_posix()
    anatomy = get_project_anatomy(project_name)
    success, formatted_path = anatomy.find_root_template_from_path(posix_path)
    return formatted_path if success else path

get_project_anatomy(project_name)

Get anatomy from project name.

Source code in client/ayon_workflow/utils.py
16
17
18
19
20
21
22
23
24
25
26
27
28
def get_project_anatomy(project_name: str):
    """ Get anatomy from project name.
    """
    # Get anatomy from cache.
    if project_name in _ANATOMY_CACHE:
        anatomy = _ANATOMY_CACHE[project_name]

    else:
        from ayon_core.pipeline import Anatomy
        anatomy = Anatomy(project_name)
        _ANATOMY_CACHE[project_name] = anatomy

    return anatomy

remap_to_path(path, project_name)

Remap provided path to root if possible.

Source code in client/ayon_workflow/utils.py
31
32
33
34
35
36
37
38
39
def remap_to_path(
        path: str,
        project_name: str,
    ) -> str:
    """ Remap provided path to root if possible.
    """
    anatomy = get_project_anatomy(project_name)
    new_path = anatomy.fill_root(str(Path(path)))
    return str(Path(new_path))  # standardize "/" vs "\"