Esempio n. 1
0
def get_folder_from_asset_type(asset):
    if asset is not None:
        asset_type = assets_service.get_asset_type(asset["entity_type_id"])
        folder = asset_type["name"]
    else:
        raise MalformedFileTreeException("Given asset is null.")
    return folder
Esempio n. 2
0
def get_folder_from_temporal_entity(entity):
    if entity is not None:
        entity = entities_service.get_entity(entity["id"])
        folder = entity["name"]
    else:
        raise MalformedFileTreeException("Given temporal entity is null.")
    return folder
Esempio n. 3
0
def get_folder_from_datatype(
    datatype,
    entity=None,
    task=None,
    task_type=None,
    software=None,
    output_type=None,
    name="",
    asset_instance=None,
    asset=None,
    representation="",
    revision=1,
    field="name",
):
    if datatype == "Project":
        folder = get_folder_from_project(entity)
    elif datatype == "Task":
        folder = get_folder_from_task(task)
    elif datatype == "TaskType":
        folder = get_folder_from_task_type(task, task_type, field)
    elif datatype == "Department":
        folder = get_folder_from_department(task, field)
    elif datatype == "Shot":
        folder = get_folder_from_shot(entity)
    elif datatype == "TemporalEntity":
        folder = get_folder_from_temporal_entity(entity)
    elif datatype == "TemporalEntityType":
        folder = get_folder_from_temporal_entity_type(entity)
    elif datatype == "AssetType":
        if asset is None:
            folder = get_folder_from_asset_type(entity)
        else:
            folder = get_folder_from_asset_type(asset)
    elif datatype == "Sequence":
        folder = get_folder_from_sequence(entity)
    elif datatype == "Episode":
        folder = get_folder_from_episode(entity)
    elif datatype == "Asset":
        if asset is None:
            folder = get_folder_from_asset(entity)
        else:
            folder = get_folder_from_asset(asset)
    elif datatype == "Software":
        folder = get_folder_from_software(software, field)
    elif datatype == "OutputType":
        folder = get_folder_from_output_type(output_type, field)
    elif datatype == "Scene":
        folder = get_folder_from_scene(entity)
    elif datatype == "Instance":
        folder = get_folder_from_asset_instance(asset_instance, field)
    elif datatype == "Representation":
        folder = get_folder_from_representation(representation)
    elif datatype in ["Name", "OutputFile", "WorkingFile"]:
        folder = name
    elif datatype == "Version" or datatype == "Revision":
        folder = get_folder_from_revision(revision)
    else:
        raise MalformedFileTreeException("Unknown data type: %s." % datatype)

    return folder
Esempio n. 4
0
def get_root_path(tree, mode, sep):
    if tree is None:
        raise MalformedFileTreeException(
            "No tree can be found for given project.")

    if mode not in tree:
        raise MalformedFileTreeException(
            "Mode %s cannot be found on given tree." % mode)

    try:
        mountpoint = tree[mode]["mountpoint"]
        root = tree[mode]["root"]
    except KeyError:
        raise MalformedFileTreeException(
            "Can't find given mode (%s) in given tree." % mode)
    return "%s%s%s%s" % (mountpoint, sep, root, sep)
Esempio n. 5
0
def get_folder_from_temporal_entity_type(entity):
    if entity is not None:
        entity_type = entities_service.get_entity_type(entity["entity_type_id"])
        folder = entity_type["name"].lower()
    else:
        raise MalformedFileTreeException("Given temporal entity type is null.")
    return folder
Esempio n. 6
0
def get_root_path(tree, mode, sep):
    try:
        mountpoint = tree[mode]["mountpoint"]
        root = tree[mode]["root"]
    except KeyError:
        raise MalformedFileTreeException(
            "Can't find given mode (%s) in given tree." % mode)
    return "%s%s%s%s" % (mountpoint, sep, root, sep)