Skip to content

Commit

Permalink
use new method name and fix issues with string conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
iLLiCiTiT committed Mar 19, 2024
1 parent eaf580b commit e5fe964
Show file tree
Hide file tree
Showing 27 changed files with 83 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def process(self, instance):
m_anatomy_key = self.anatomy_template_key_metadata

# get folder and path for rendering images from celaction
r_template_item = anatomy.get_template("publish", r_anatomy_key)
r_template_item = anatomy.get_template_item("publish", r_anatomy_key)
render_dir = r_template_item["directory"].format_strict(anatomy_data)
render_path = r_template_item["path"].format_strict(anatomy_data)
self.log.debug("__ render_path: `{}`".format(render_path))
Expand All @@ -50,7 +50,9 @@ def process(self, instance):
instance.data["path"] = render_path

# get anatomy for published renders folder path
m_template_item = anatomy.get_template("publish", m_anatomy_key)
m_template_item = anatomy.get_template_item(
"publish", m_anatomy_key, default=None
)
if m_template_item is not None:
metadata_path = m_template_item["directory"].format_strict(
anatomy_data
Expand Down
6 changes: 4 additions & 2 deletions client/ayon_core/hosts/hiero/api/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,9 @@ def sync_avalon_data_to_workfile():
project_name = get_current_project_name()

anatomy = Anatomy(project_name)
work_template = anatomy.get_template("work", "default", "path")
work_template = anatomy.get_template_item(
"work", "default", "path"
)
work_root = anatomy.root_value_for_template(work_template)
active_project_root = (
os.path.join(work_root, project_name)
Expand Down Expand Up @@ -825,7 +827,7 @@ def eventHandler(self, event):
# root_node = hiero.core.nuke.RootNode()
#
# anatomy = Anatomy(get_current_project_name())
# work_template = anatomy.get_template("work", "default", "path")
# work_template = anatomy.get_template_item("work", "default", "path")
# root_path = anatomy.root_value_for_template(work_template)
#
# nuke_script.addNode(root_node)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ def process(self, instance):

template_data = copy.deepcopy(instance.data["anatomyData"])
anatomy = instance.context.data["anatomy"]
publish_template = anatomy.get_template("publish", "default", "file")
publish_template = anatomy.get_template_item(
"publish", "default", "file"
)
published_maya_path = publish_template.format(template_data)
published_basename, _ = os.path.splitext(published_maya_path)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def process(self, instance):
template_data = copy.deepcopy(instance.data["anatomyData"])
template_data.update({"ext": "xgen"})
anatomy = instance.context.data["anatomy"]
file_template = anatomy.get_template("publish", "default", "file")
file_template = anatomy.get_template_item("publish", "default", "file")
xgen_filename = file_template.format(template_data)

xgen_path = os.path.join(
Expand Down
6 changes: 3 additions & 3 deletions client/ayon_core/hosts/photoshop/api/launch_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,13 +392,13 @@ def _get_last_workfile_path(self, project_name, folder_path, task_name):
)
data["root"] = anatomy.roots

work_template = anatomy.get_template("work", template_key)
work_template = anatomy.get_template_item("work", template_key)

# Define saving file extension
extensions = host.get_workfile_extensions()

work_root = str(work_template["directory"].format_strict(data))
file_template = str(work_template["file"])
work_root = work_template["directory"].format_strict(data)
file_template = work_template["file"].template
last_workfile_path = get_last_workfile(
work_root, file_template, data, extensions, True
)
Expand Down
6 changes: 3 additions & 3 deletions client/ayon_core/hosts/tvpaint/plugins/load/load_workfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def load(self, context, name, namespace, options):
)
data["root"] = anatomy.roots

work_template = anatomy.get_template("work", template_key)
work_template = anatomy.get_template_item("work", template_key)

# Define saving file extension
extensions = host.get_workfile_extensions()
Expand All @@ -93,9 +93,9 @@ def load(self, context, name, namespace, options):

data["ext"] = extension.lstrip(".")

work_root = str(work_template["directory"].format_strict(data))
work_root = work_template["directory"].format_strict(data)
version = get_last_workfile_with_version(
work_root, str(work_template["file"]), data, extensions
work_root, work_template["file"].template, data, extensions
)[1]

if version is None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def _get_work_filename(self):
self.host_name,
)
# Fill templates
template_obj = anatomy.get_template(
template_obj = anatomy.get_template_item(
"work", workfile_template_key, "file"
)

Expand Down
6 changes: 3 additions & 3 deletions client/ayon_core/lib/applications.py
Original file line number Diff line number Diff line change
Expand Up @@ -1862,9 +1862,9 @@ def _prepare_last_workfile(data, workdir, addons_manager):
project_settings=project_settings
)
# Find last workfile
file_template = str(
anatomy.get_template("work", template_key, "file")
)
file_template = anatomy.get_template_item(
"work", template_key, "file"
).template

workdir_data.update({
"version": 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ def payload_submit(self,
script_name = os.path.basename(script_path)

anatomy = instance.context.data["anatomy"]
publish_template = anatomy.get_template("publish", "default", "path")
publish_template = anatomy.get_template_item(
"publish", "default", "path"
)
for item in instance.context:
if "workfile" in item.data["productType"]:
msg = "Workfile (scene) must be published along"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ def process(self, instance):
script_path = context.data["currentFile"]

anatomy = instance.context.data["anatomy"]
publish_template = anatomy.get_template("publish", "default", "path")
publish_template = anatomy.get_template_item(
"publish", "default", "path"
)
for item in context:
if "workfile" in item.data["families"]:
msg = "Workfile (scene) must be published along"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,9 @@ def _get_published_workfile_path(self, context):
AbstractSubmitDeadline"""
anatomy = context.data["anatomy"]
# WARNING Hardcoded template name 'default' > may not be used
publish_template = anatomy.get_template("publish", "default", "path")
publish_template = anatomy.get_template_item(
"publish", "default", "path"
)
for instance in context:
if (
instance.data["productType"] != "workfile"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ def _get_publish_folder(self, anatomy, template_data,
"type": product_type,
}

render_dir_template = anatomy.get_template(
render_dir_template = anatomy.get_template_item(
"publish", template_name, "directory"
)
return render_dir_template.format_strict(template_data)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ def _get_publish_folder(self, anatomy, template_data,
"type": product_type,
}

render_dir_template = anatomy.get_template(
render_dir_template = anatomy.get_template_item(
"publish", template_name, "directory"
)
return render_dir_template.format_strict(template_data)
Expand Down
2 changes: 1 addition & 1 deletion client/ayon_core/pipeline/context_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ def get_workdir_from_session(session=None, template_key=None):
)

anatomy = Anatomy(project_name)
template_obj = anatomy.get_template("work", template_key, "directory")
template_obj = anatomy.get_template_item("work", template_key, "directory")
path = template_obj.format_strict(template_data)
if path:
path = os.path.normpath(path)
Expand Down
17 changes: 10 additions & 7 deletions client/ayon_core/pipeline/delivery.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ def check_destination_path(
"""

anatomy_data.update(datetime_data)
path_template = anatomy.get_template("delivery", template_name, "path")
path_template = anatomy.get_template_item(
"delivery", template_name, "path"
)
dest_path = path_template.format(anatomy_data)
report_items = collections.defaultdict(list)

Expand Down Expand Up @@ -150,7 +152,9 @@ def deliver_single_file(
if format_dict:
anatomy_data = copy.deepcopy(anatomy_data)
anatomy_data["root"] = format_dict["root"]
template_obj = anatomy.get_template("delivery", template_name, "path")
template_obj = anatomy.get_template_item(
"delivery", template_name, "path"
)
delivery_path = template_obj.format_strict(anatomy_data)

# Backwards compatibility when extension contained `.`
Expand Down Expand Up @@ -220,8 +224,8 @@ def hash_path_exist(myPath):
report_items["Source file was not found"].append(msg)
return report_items, 0

delivery_template = anatomy.get_template(
"delivery", template_name, "path"
delivery_template = anatomy.get_template_item(
"delivery", template_name, "path", default=None
)
if delivery_template is None:
msg = (
Expand All @@ -233,7 +237,7 @@ def hash_path_exist(myPath):

# Check if 'frame' key is available in template which is required
# for sequence delivery
if "{frame" not in delivery_template:
if "{frame" not in delivery_template.template:
msg = (
"Delivery template \"{}\" in anatomy of project \"{}\""
"does not contain '{{frame}}' key to fill. Delivery of sequence"
Expand Down Expand Up @@ -278,8 +282,7 @@ def hash_path_exist(myPath):
anatomy_data["frame"] = frame_indicator
if format_dict:
anatomy_data["root"] = format_dict["root"]
template_obj = anatomy.get_template("delivery", template_name, "path")
delivery_path = template_obj.format_strict(anatomy_data)
delivery_path = delivery_template.format_strict(anatomy_data)

delivery_path = os.path.normpath(delivery_path.replace("\\", "/"))
delivery_folder = os.path.dirname(delivery_path)
Expand Down
2 changes: 1 addition & 1 deletion client/ayon_core/pipeline/farm/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def from_published_scene(instance, replace_in_path=True):
template_data["comment"] = None

anatomy = instance.context.data['anatomy']
template_obj = anatomy.get_template("publish", "default", "path")
template_obj = anatomy.get_template_item("publish", "default", "path")
template_filled = template_obj.format_strict(template_data)
file_path = os.path.normpath(template_filled)

Expand Down
8 changes: 4 additions & 4 deletions client/ayon_core/pipeline/publish/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -743,8 +743,8 @@ def get_custom_staging_dir_info(

template_name = profile["template_name"] or TRANSIENT_DIR_TEMPLATE

custom_staging_dir = anatomy.get_template(
"staging", template_name, "directory"
custom_staging_dir = anatomy.get_template_item(
"staging", template_name, "directory", default=None
)
if custom_staging_dir is None:
raise ValueError((
Expand All @@ -753,7 +753,7 @@ def get_custom_staging_dir_info(
).format(project_name, template_name))
is_persistent = profile["custom_staging_dir_persistent"]

return str(custom_staging_dir), is_persistent
return custom_staging_dir.template, is_persistent


def get_published_workfile_instance(context):
Expand Down Expand Up @@ -805,7 +805,7 @@ def replace_with_published_scene_path(instance, replace_in_path=True):
template_data["comment"] = None

anatomy = instance.context.data["anatomy"]
template = anatomy.get_template("publish", "default", "path")
template = anatomy.get_template_item("publish", "default", "path")
template_filled = template.format_strict(template_data)
file_path = os.path.normpath(template_filled)

Expand Down
4 changes: 2 additions & 2 deletions client/ayon_core/pipeline/usdlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,8 @@ def get_usd_master_path(folder_entity, product_name, representation):
"version": 0, # stub version zero
})

template_obj = anatomy.get_template(
"publish", "default","path"
template_obj = anatomy.get_template_item(
"publish", "default", "path"
)
path = template_obj.format_strict(template_data)

Expand Down
4 changes: 3 additions & 1 deletion client/ayon_core/pipeline/workfile/path_resolving.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ def get_workdir_with_workdir_data(
project_settings
)

template_obj = anatomy.get_template("work", template_key, "directory")
template_obj = anatomy.get_template_item(
"work", template_key, "directory"
)
# Output is TemplateResult object which contain useful data
output = template_obj.format_strict(workdir_data)
if output:
Expand Down
4 changes: 2 additions & 2 deletions client/ayon_core/plugins/actions/open_file_explorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def _get_workdir(self, project_name, folder_path, task_name):
data = get_template_data(project_entity, folder_entity, task_entity)

anatomy = Anatomy(project_name)
workdir = anatomy.get_template(
workdir = anatomy.get_template_item(
"work", "default", "folder"
).format(data)

Expand All @@ -87,7 +87,7 @@ def _get_workdir(self, project_name, folder_path, task_name):
return valid_workdir

data.pop("task", None)
workdir = anatomy.get_template(
workdir = anatomy.get_template_item(
"work", "default", "folder"
).format(data)
valid_workdir = self._find_first_filled_path(workdir)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ def process(self, instance):

template_name = self.get_template_name(instance)
anatomy = instance.context.data["anatomy"]
publish_path_template = anatomy.get_template(
publish_path_template = anatomy.get_template_item(
"publish", template_name, "path"
)
).template
template = os.path.normpath(publish_path_template)
self.log.debug(
">> template: {}".format(template))
Expand Down
2 changes: 1 addition & 1 deletion client/ayon_core/plugins/publish/collect_resources_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def process(self, instance):
"representation": "TEMP"
})

publish_templates = anatomy.get_template(
publish_templates = anatomy.get_template_item(
"publish", "default", "directory"
)
publish_folder = os.path.normpath(
Expand Down
4 changes: 2 additions & 2 deletions client/ayon_core/plugins/publish/integrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -665,9 +665,9 @@ def prepare_representation(

self.log.debug("Anatomy template name: {}".format(template_name))
anatomy = instance.context.data["anatomy"]
publish_template = anatomy.get_template("publish", template_name)
publish_template = anatomy.get_template_item("publish", template_name)
path_template_obj = publish_template["path"]
template = os.path.normpath(path_template_obj)
template = path_template_obj.template.replace("\\", "/")

is_udim = bool(repre.get("udim"))

Expand Down
12 changes: 8 additions & 4 deletions client/ayon_core/plugins/publish/integrate_hero_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ def process(self, instance):
project_name = anatomy.project_name

template_key = self._get_template_key(project_name, instance)
hero_template = anatomy.get_template("hero", template_key, "path")
hero_template = anatomy.get_template_item(
"hero", template_key, "path", default=None
)

if hero_template is None:
self.log.warning((
Expand Down Expand Up @@ -320,7 +322,7 @@ def integrate_instance(
try:
src_to_dst_file_paths = []
repre_integrate_data = []
path_template_obj = anatomy.get_template(
path_template_obj = anatomy.get_template_item(
"hero", template_key, "path"
)
for repre_info in published_repres.values():
Expand All @@ -335,7 +337,9 @@ def integrate_instance(
anatomy_data.pop("version", None)

# Get filled path to repre context
template_filled = path_template_obj.format_strict(anatomy_data)
template_filled = path_template_obj.format_strict(
anatomy_data
)
repre_context = template_filled.used_values
for key in self.db_representation_context_keys:
value = anatomy_data.get(key)
Expand Down Expand Up @@ -538,7 +542,7 @@ def get_publish_dir(self, instance, template_key):
"originalBasename": instance.data.get("originalBasename")
})

template_obj = anatomy.get_template(
template_obj = anatomy.get_template_item(
"hero", template_key, "directory"
)
publish_folder = os.path.normpath(
Expand Down
Loading

0 comments on commit e5fe964

Please sign in to comment.