Skip to content

lib

fill_placeholder(placeholder, workfile_path, context)

Replaces placeholder with actual path to representation

Parameters:

Name Type Description Default
placeholder str

in format PLACEHOLDER_VALUE_PATTERN

required
workfile_path str

absolute path to opened workfile

required
context dict

contains context data from launch context

required

Returns: (dict, str) path to resolved representation file which should be used instead of placeholder Raises (PlaceholderFillException) if path cannot be resolved (cannot find product, version etc.)

Source code in client/ayon_wrap/api/lib.py
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
def fill_placeholder(placeholder, workfile_path, context):
    """Replaces placeholder with actual path to representation

    Args:
        placeholder (str): in format PLACEHOLDER_VALUE_PATTERN
        workfile_path (str): absolute path to opened workfile
        context (dict): contains context data from launch context
    Returns:
        (dict, str) path to resolved representation file which should be used
            instead of placeholder
    Raises
        (PlaceholderFillException) if path cannot be resolved (cannot find
        product, version etc.)

    """
    token_and_values = get_token_and_values(placeholder)

    project_name = context["project_name"]

    folder_token = token_and_values["folder_token"]
    folder_entity = _get_folder_entity(project_name, folder_token, context)
    folder_id = folder_entity["id"]

    product_name = token_and_values["product_name"]
    product_id = _get_product_id(
        project_name,
        folder_id,
        product_name,
        folder_entity["path"]
    )

    version_val = token_and_values["version"]
    version_id = _get_version(
        project_name,
        product_name,
        product_id,
        version_val,
        workfile_path
    )

    ext = token_and_values["ext"]
    repre, repre_path = _get_repre_and_path(
        project_name, product_name, ext, version_id)

    return repre, repre_path

find_variant_key(application_manager, host)

Searches for latest installed variant for 'host'

Returns (string) (optional) Raises: (ValueError) if no variant found

Source code in client/ayon_wrap/api/lib.py
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
def find_variant_key(application_manager, host):
    """Searches for latest installed variant for 'host'

        Args:
            application_manager (ApplicationManager)
            host (str)
        Returns
            (string) (optional)
        Raises:
            (ValueError) if no variant found
    """
    app_group = application_manager.app_groups.get(host)
    if not app_group or not app_group.enabled:
        raise ValueError("No application '{}' configured".format(host))

    found_variant_key = None
    # finds most up-to-date variant if any installed
    sorted_variants = collections.OrderedDict(
        sorted(app_group.variants.items()))
    for variant_key, variant in sorted_variants.items():
        for executable in variant.executables:
            if executable.exists():
                found_variant_key = variant_key

    if not found_variant_key:
        raise ValueError("No executable for '{}' found".format(host))

    return found_variant_key

get_multiple_templates_profile(project_settings, task_name, task_type, log=None)

Returns configured profile for current context

Source code in client/ayon_wrap/api/lib.py
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
def get_multiple_templates_profile(
        project_settings, task_name, task_type, log=None):
    """Returns configured profile for current context"""
    wrap_settings = project_settings["wrap"]
    multiple_templates_profiles = (
        wrap_settings)["multiple_templates_per_tasks"]["profiles"]
    if not multiple_templates_profiles:
        return

    found_profile = filter_profiles(
        multiple_templates_profiles,
        {
            "task_names": task_name,
            "task_types": task_type,
        },
        logger=log
    )

    return found_profile