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

Commit

Permalink
Merge pull request #885 from pypeclub/hotfix/nuke-loader-sequence-hashes
Browse files Browse the repository at this point in the history
fix(nuke): improving of hashing path
  • Loading branch information
mkolar authored Jan 15, 2021
2 parents 1a432a3 + 1fd5822 commit a4d7e75
Showing 1 changed file with 21 additions and 14 deletions.
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

0 comments on commit a4d7e75

Please sign in to comment.