mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 08:24:53 +01:00
Merge pull request #5024 from moonyuet/enhancement/OP-3622_Delivery-renamed-frame-numbers
This commit is contained in:
commit
5991a4a8c9
2 changed files with 53 additions and 4 deletions
|
|
@ -178,7 +178,9 @@ def deliver_sequence(
|
|||
anatomy_data,
|
||||
format_dict,
|
||||
report_items,
|
||||
log
|
||||
log,
|
||||
has_renumbered_frame=False,
|
||||
new_frame_start=0
|
||||
):
|
||||
""" For Pype2(mainly - works in 3 too) where representation might not
|
||||
contain files.
|
||||
|
|
@ -294,17 +296,30 @@ def deliver_sequence(
|
|||
src_head = src_collection.head
|
||||
src_tail = src_collection.tail
|
||||
uploaded = 0
|
||||
first_frame = min(src_collection.indexes)
|
||||
for index in src_collection.indexes:
|
||||
src_padding = src_collection.format("{padding}") % index
|
||||
src_file_name = "{}{}{}".format(src_head, src_padding, src_tail)
|
||||
src = os.path.normpath(
|
||||
os.path.join(dir_path, src_file_name)
|
||||
)
|
||||
|
||||
dst_padding = dst_collection.format("{padding}") % index
|
||||
dst_index = index
|
||||
if has_renumbered_frame:
|
||||
# Calculate offset between first frame and current frame
|
||||
# - '0' for first frame
|
||||
offset = new_frame_start - first_frame
|
||||
# Add offset to new frame start
|
||||
dst_index = index + offset
|
||||
if dst_index < 0:
|
||||
msg = "Renumber frame has a smaller number than original frame" # noqa
|
||||
report_items[msg].append(src_file_name)
|
||||
log.warning("{} <{}>".format(msg, context))
|
||||
return report_items, 0
|
||||
dst_padding = dst_collection.format("{padding}") % dst_index
|
||||
dst = "{}{}{}".format(dst_head, dst_padding, dst_tail)
|
||||
log.debug("Copying single: {} -> {}".format(src, dst))
|
||||
_copy_file(src, dst)
|
||||
|
||||
uploaded += 1
|
||||
|
||||
return report_items, uploaded
|
||||
|
|
|
|||
|
|
@ -95,6 +95,12 @@ class DeliveryOptionsDialog(QtWidgets.QDialog):
|
|||
template_label.setCursor(QtGui.QCursor(QtCore.Qt.IBeamCursor))
|
||||
template_label.setTextInteractionFlags(QtCore.Qt.TextSelectableByMouse)
|
||||
|
||||
renumber_frame = QtWidgets.QCheckBox()
|
||||
|
||||
first_frame_start = QtWidgets.QSpinBox()
|
||||
max_int = (1 << 32) // 2
|
||||
first_frame_start.setRange(0, max_int - 1)
|
||||
|
||||
root_line_edit = QtWidgets.QLineEdit()
|
||||
|
||||
repre_checkboxes_layout = QtWidgets.QFormLayout()
|
||||
|
|
@ -118,6 +124,8 @@ class DeliveryOptionsDialog(QtWidgets.QDialog):
|
|||
input_layout.addRow("Selected representations", selected_label)
|
||||
input_layout.addRow("Delivery template", dropdown)
|
||||
input_layout.addRow("Template value", template_label)
|
||||
input_layout.addRow("Renumber Frame", renumber_frame)
|
||||
input_layout.addRow("Renumber start frame", first_frame_start)
|
||||
input_layout.addRow("Root", root_line_edit)
|
||||
input_layout.addRow("Representations", repre_checkboxes_layout)
|
||||
|
||||
|
|
@ -145,6 +153,8 @@ class DeliveryOptionsDialog(QtWidgets.QDialog):
|
|||
self.selected_label = selected_label
|
||||
self.template_label = template_label
|
||||
self.dropdown = dropdown
|
||||
self.first_frame_start = first_frame_start
|
||||
self.renumber_frame = renumber_frame
|
||||
self.root_line_edit = root_line_edit
|
||||
self.progress_bar = progress_bar
|
||||
self.text_area = text_area
|
||||
|
|
@ -181,6 +191,8 @@ class DeliveryOptionsDialog(QtWidgets.QDialog):
|
|||
datetime_data = get_datetime_data()
|
||||
template_name = self.dropdown.currentText()
|
||||
format_dict = get_format_dict(self.anatomy, self.root_line_edit.text())
|
||||
renumber_frame = self.renumber_frame.isChecked()
|
||||
frame_offset = self.first_frame_start.value()
|
||||
for repre in self._representations:
|
||||
if repre["name"] not in selected_repres:
|
||||
continue
|
||||
|
|
@ -218,9 +230,31 @@ class DeliveryOptionsDialog(QtWidgets.QDialog):
|
|||
src_paths.append(src_path)
|
||||
sources_and_frames = collect_frames(src_paths)
|
||||
|
||||
frames = set(sources_and_frames.values())
|
||||
frames.discard(None)
|
||||
first_frame = None
|
||||
if frames:
|
||||
first_frame = min(frames)
|
||||
|
||||
for src_path, frame in sources_and_frames.items():
|
||||
args[0] = src_path
|
||||
if frame:
|
||||
# Renumber frames
|
||||
if renumber_frame and frame is not None:
|
||||
# Calculate offset between
|
||||
# first frame and current frame
|
||||
# - '0' for first frame
|
||||
offset = frame_offset - int(first_frame)
|
||||
# Add offset to new frame start
|
||||
dst_frame = int(frame) + offset
|
||||
if dst_frame < 0:
|
||||
msg = "Renumber frame has a smaller number than original frame" # noqa
|
||||
report_items[msg].append(src_path)
|
||||
self.log.warning("{} <{}>".format(
|
||||
msg, dst_frame))
|
||||
continue
|
||||
frame = dst_frame
|
||||
|
||||
if frame is not None:
|
||||
anatomy_data["frame"] = frame
|
||||
new_report_items, uploaded = deliver_single_file(*args)
|
||||
report_items.update(new_report_items)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue