Delivery in LibraryLoader - fix broken sequence delivery

This commit is contained in:
Petr Kalis 2021-05-25 17:57:36 +02:00
parent dd04e7833b
commit 53ef81dc0e
2 changed files with 40 additions and 4 deletions

View file

@ -4,6 +4,35 @@ import shutil
import clique
import collections
def collect_frames(files):
"""
Returns dict of source path and its frame, if from sequence
Uses clique as most precise solution
Args:
files(list): list of source paths
Returns:
(dict): {'/asset/subset_v001.0001.png': '0001', ....}
"""
collections, remainder = clique.assemble(files)
sources_and_frames = {}
if collections:
for collection in collections:
src_head = collection.head
src_tail = collection.tail
for index in collection.indexes:
src_frame = collection.format("{padding}") % index
src_file_name = "{}{}{}".format(src_head, src_frame,
src_tail)
sources_and_frames[src_file_name] = src_frame
else:
sources_and_frames[remainder.pop()] = None
return sources_and_frames
def sizeof_fmt(num, suffix='B'):
"""Returns formatted string with size in appropriate unit"""
@ -166,7 +195,6 @@ def process_single_file(
os.makedirs(delivery_folder)
log.debug("Copying single: {} -> {}".format(src_path, delivery_path))
print("Copying single: {} -> {}".format(src_path, delivery_path))
copy_file(src_path, delivery_path)
return report_items, 1

View file

@ -1,4 +1,4 @@
import collections
from collections import defaultdict
import copy
from Qt import QtWidgets, QtCore, QtGui
@ -15,7 +15,8 @@ from openpype.lib.delivery import (
get_format_dict,
check_destination_path,
process_single_file,
process_sequence
process_sequence,
collect_frames
)
@ -158,7 +159,7 @@ class DeliveryOptionsDialog(QtWidgets.QDialog):
self.btn_delivery.setEnabled(False)
QtWidgets.QApplication.processEvents()
report_items = collections.defaultdict(list)
report_items = defaultdict(list)
selected_repres = self._get_selected_repres()
@ -194,9 +195,16 @@ class DeliveryOptionsDialog(QtWidgets.QDialog):
]
if repre.get("files"):
src_paths = []
for repre_file in repre["files"]:
src_path = self.anatomy.fill_root(repre_file["path"])
src_paths.append(src_path)
sources_and_frames = collect_frames(src_paths)
for src_path, frame in sources_and_frames.items():
args[0] = src_path
if frame:
anatomy_data["frame"] = frame
new_report_items, uploaded = process_single_file(*args)
report_items.update(new_report_items)
self._update_progress(uploaded)