mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 08:24:53 +01:00
Merge pull request #397 from pypeclub/bugfix/delivery_action_can_work_with_entered_path
Delivery action can now work with entered path
This commit is contained in:
commit
1802ea5ec3
1 changed files with 47 additions and 19 deletions
|
|
@ -81,13 +81,15 @@ class Delivery(BaseAction):
|
||||||
anatomy = Anatomy(project_name)
|
anatomy = Anatomy(project_name)
|
||||||
new_anatomies = []
|
new_anatomies = []
|
||||||
first = None
|
first = None
|
||||||
for key in (anatomy.templates.get("delivery") or {}):
|
for key, template in (anatomy.templates.get("delivery") or {}).items():
|
||||||
new_anatomies.append({
|
# Use only keys with `{root}` or `{root[*]}` in value
|
||||||
"label": key,
|
if isinstance(template, str) and "{root" in template:
|
||||||
"value": key
|
new_anatomies.append({
|
||||||
})
|
"label": key,
|
||||||
if first is None:
|
"value": key
|
||||||
first = key
|
})
|
||||||
|
if first is None:
|
||||||
|
first = key
|
||||||
|
|
||||||
skipped = False
|
skipped = False
|
||||||
# Add message if there are any common components
|
# Add message if there are any common components
|
||||||
|
|
@ -293,6 +295,20 @@ class Delivery(BaseAction):
|
||||||
repres_to_deliver.append(repre)
|
repres_to_deliver.append(repre)
|
||||||
|
|
||||||
anatomy = Anatomy(project_name)
|
anatomy = Anatomy(project_name)
|
||||||
|
|
||||||
|
format_dict = {}
|
||||||
|
if location_path:
|
||||||
|
location_path = location_path.replace("\\", "/")
|
||||||
|
root_names = anatomy.root_names_from_templates(
|
||||||
|
anatomy.templates["delivery"]
|
||||||
|
)
|
||||||
|
if root_names is None:
|
||||||
|
format_dict["root"] = location_path
|
||||||
|
else:
|
||||||
|
format_dict["root"] = {}
|
||||||
|
for name in root_names:
|
||||||
|
format_dict["root"][name] = location_path
|
||||||
|
|
||||||
for repre in repres_to_deliver:
|
for repre in repres_to_deliver:
|
||||||
# Get destination repre path
|
# Get destination repre path
|
||||||
anatomy_data = copy.deepcopy(repre["context"])
|
anatomy_data = copy.deepcopy(repre["context"])
|
||||||
|
|
@ -339,25 +355,33 @@ class Delivery(BaseAction):
|
||||||
repre_path = self.path_from_represenation(repre, anatomy)
|
repre_path = self.path_from_represenation(repre, anatomy)
|
||||||
# TODO add backup solution where root of path from component
|
# TODO add backup solution where root of path from component
|
||||||
# is repalced with root
|
# is repalced with root
|
||||||
if not frame:
|
args = (
|
||||||
self.process_single_file(
|
repre_path,
|
||||||
repre_path, anatomy, anatomy_name, anatomy_data
|
anatomy,
|
||||||
)
|
anatomy_name,
|
||||||
|
anatomy_data,
|
||||||
|
format_dict
|
||||||
|
)
|
||||||
|
|
||||||
|
if not frame:
|
||||||
|
self.process_single_file(*args)
|
||||||
else:
|
else:
|
||||||
self.process_sequence(
|
self.process_sequence(*args)
|
||||||
repre_path, anatomy, anatomy_name, anatomy_data
|
|
||||||
)
|
|
||||||
|
|
||||||
self.db_con.uninstall()
|
self.db_con.uninstall()
|
||||||
|
|
||||||
return self.report()
|
return self.report()
|
||||||
|
|
||||||
def process_single_file(
|
def process_single_file(
|
||||||
self, repre_path, anatomy, anatomy_name, anatomy_data
|
self, repre_path, anatomy, anatomy_name, anatomy_data, format_dict
|
||||||
):
|
):
|
||||||
anatomy_filled = anatomy.format(anatomy_data)
|
anatomy_filled = anatomy.format(anatomy_data)
|
||||||
delivery_path = anatomy_filled["delivery"][anatomy_name]
|
if format_dict:
|
||||||
|
template_result = anatomy_filled["delivery"][anatomy_name]
|
||||||
|
delivery_path = template_result.rootless.format(**format_dict)
|
||||||
|
else:
|
||||||
|
delivery_path = anatomy_filled["delivery"][anatomy_name]
|
||||||
|
|
||||||
delivery_folder = os.path.dirname(delivery_path)
|
delivery_folder = os.path.dirname(delivery_path)
|
||||||
if not os.path.exists(delivery_folder):
|
if not os.path.exists(delivery_folder):
|
||||||
os.makedirs(delivery_folder)
|
os.makedirs(delivery_folder)
|
||||||
|
|
@ -365,7 +389,7 @@ class Delivery(BaseAction):
|
||||||
self.copy_file(repre_path, delivery_path)
|
self.copy_file(repre_path, delivery_path)
|
||||||
|
|
||||||
def process_sequence(
|
def process_sequence(
|
||||||
self, repre_path, anatomy, anatomy_name, anatomy_data
|
self, repre_path, anatomy, anatomy_name, anatomy_data, format_dict
|
||||||
):
|
):
|
||||||
dir_path, file_name = os.path.split(str(repre_path))
|
dir_path, file_name = os.path.split(str(repre_path))
|
||||||
|
|
||||||
|
|
@ -408,8 +432,12 @@ class Delivery(BaseAction):
|
||||||
anatomy_data["frame"] = frame_indicator
|
anatomy_data["frame"] = frame_indicator
|
||||||
anatomy_filled = anatomy.format(anatomy_data)
|
anatomy_filled = anatomy.format(anatomy_data)
|
||||||
|
|
||||||
delivery_path = anatomy_filled["delivery"][anatomy_name]
|
if format_dict:
|
||||||
print(delivery_path)
|
template_result = anatomy_filled["delivery"][anatomy_name]
|
||||||
|
delivery_path = template_result.rootless.format(**format_dict)
|
||||||
|
else:
|
||||||
|
delivery_path = anatomy_filled["delivery"][anatomy_name]
|
||||||
|
|
||||||
delivery_folder = os.path.dirname(delivery_path)
|
delivery_folder = os.path.dirname(delivery_path)
|
||||||
dst_head, dst_tail = delivery_path.split(frame_indicator)
|
dst_head, dst_tail = delivery_path.split(frame_indicator)
|
||||||
dst_padding = src_collection.padding
|
dst_padding = src_collection.padding
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue