Asset Pipeline v2 #145

Closed
Nick Alberelli wants to merge 431 commits from (deleted):feature/asset-pipeline-v2 into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
Showing only changes of commit f89455bf00 - Show all commits

View File

@ -26,27 +26,50 @@ from .util import get_storage_of_id
DELIMITER = "." DELIMITER = "."
def get_target_suffix(suffix: str): def get_target_suffix(suffix: str) -> str:
"""Get the corrisponding suffix for a given suffix
Args:
suffix (str): Suffix for External or Local Datablock
Returns:
str: Returns External Suffix if given Local suffix for vice-versa
"""
if suffix.endswith(constants.EXTERNAL_SUFFIX): if suffix.endswith(constants.EXTERNAL_SUFFIX):
return constants.LOCAL_SUFFIX return constants.LOCAL_SUFFIX
if suffix.endswith(constants.LOCAL_SUFFIX): if suffix.endswith(constants.LOCAL_SUFFIX):
return constants.EXTERNAL_SUFFIX return constants.EXTERNAL_SUFFIX
def get_target_name(name: str, occurrence=1) -> str: def get_target_name(name: str) -> str:
"""Get the corrisponding target name for a given datablock's suffix.
Suffixes are set by the add_suffix_to_hierarchy() function prior to
calling this function.
Args:
name (str): Name of a given datablock including it's suffix
Returns:
str: Returns datablock name with the opposite suffix
"""
old = name.split(DELIMITER)[-1] old = name.split(DELIMITER)[-1]
new = get_target_suffix(old) new = get_target_suffix(old)
li = name.rsplit(old, occurrence) li = name.rsplit(old, 1)
return new.join(li) return new.join(li)
def get_basename(name): def get_basename(name: str) -> str:
"""Returns the name of an asset without it's suffix"""
return DELIMITER.join(name.split(DELIMITER)[:-1]) return DELIMITER.join(name.split(DELIMITER)[:-1])
def remove_suffix_from_hierarchy(collection: bpy.types.Collection): def remove_suffix_from_hierarchy(collection: bpy.types.Collection) -> None:
"""Removes the suffix after a set delimiter from all datablocks """Removes the suffix after a set delimiter from all datablocks
referenced by a collection, itself included""" referenced by a collection, itself included
Args:
collection (bpy.types.Collection): Collection that as been suffixed
"""
ref_map = get_id_reference_map() ref_map = get_id_reference_map()
datablocks = get_all_referenced_ids(collection, ref_map) datablocks = get_all_referenced_ids(collection, ref_map)
@ -61,9 +84,14 @@ def remove_suffix_from_hierarchy(collection: bpy.types.Collection):
pass pass
def add_suffix_to_hierarchy(collection: bpy.types.Collection, suffix_base: str): def add_suffix_to_hierarchy(collection: bpy.types.Collection, suffix_base: str) -> None:
"""Add a suffix to the names of all datablocks referenced by a collection, """Add a suffix to the names of all datablocks referenced by a collection,
itself included.""" itself included.
Args:
collection (bpy.types.Collection): Collection that needs to be suffixed
suffix_base (str): Suffix to append to collection and items linked to collection
"""
suffix = f"{DELIMITER}{suffix_base}" suffix = f"{DELIMITER}{suffix_base}"