Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Nuke: improving of hashing path #885

Merged
merged 1 commit into from
Jan 15, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 21 additions & 14 deletions pype/plugins/nuke/load/load_sequence.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import re
import nuke
import contextlib
Expand Down Expand Up @@ -79,6 +80,23 @@ class LoadSequence(api.Loader):
icon = "file-video-o"
color = "white"

@staticmethod
def fix_hashes_in_path(file, repr_cont):
if "#" not in file:
dirname, basename = os.path.split(file)
frame = repr_cont.get("frame")
if frame:
max = len(basename.split(frame)) - 2
new_basename = ""
for index, split in enumerate(basename.split(frame)):
new_basename += split
if max == index:
new_basename += "#" * len(frame)
if index < max:
new_basename += frame
file = os.path.join(dirname, new_basename).replace("\\", "/")
return file

def load(self, context, name, namespace, data):
from avalon.nuke import (
containerise,
Expand Down Expand Up @@ -115,14 +133,9 @@ def load(self, context, name, namespace, data):
"Representation id `{}` is failing to load".format(repr_id))
return

file = file.replace("\\", "/")

repr_cont = context["representation"]["context"]
if "#" not in file:
frame = repr_cont.get("frame")
if frame:
padding = len(frame)
file = file.replace(frame, "#" * padding)

file = self.fix_hashes_in_path(file, repr_cont).replace("\\", "/")

read_name = "Read_{0}_{1}_{2}".format(
repr_cont["asset"],
Expand Down Expand Up @@ -247,13 +260,7 @@ def update(self, container, representation):
"Representation id `{}` is failing to load".format(repr_id))
return

file = file.replace("\\", "/")

if "#" not in file:
frame = repr_cont.get("frame")
if frame:
padding = len(frame)
file = file.replace(frame, "#" * padding)
file = self.fix_hashes_in_path(file, repr_cont).replace("\\", "/")

# Get start frame from version data
version = io.find_one({
Expand Down