Skip to content

Commit

Permalink
Merge pull request #26 from ynput/bugfix/AY-6740_CSV-ingest-match-rep…
Browse files Browse the repository at this point in the history
…resentation-data-correctly

Refactor file name handling and sequence padding logic.
  • Loading branch information
jakubjezek001 authored Sep 30, 2024
2 parents 8380ad0 + eb2c13f commit 96e4269
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions client/ayon_traypublisher/plugins/create/create_csv_ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -644,9 +644,21 @@ def _add_representation(
# convert ### string in file name to %03d
# this is for correct frame range validation
# example: file.###.exr -> file.%03d.exr
file_head = basename.split(".")[0]
if "#" in basename:
padding = len(basename.split("#")) - 1
basename = basename.replace("#" * padding, f"%0{padding}d")
seq_padding = f"%0{padding}d"
basename = basename.replace("#" * padding, seq_padding)
file_head = basename.split(seq_padding)[0]
is_sequence = True
elif "%" in basename:
pattern = re.compile(r"%\d+d|%d")
padding = pattern.findall(basename)
if not padding:
raise CreatorError(
f"File sequence padding not found in '{basename}'."
)
file_head = basename.split("%")[0]
is_sequence = True

# make absolute path to file
Expand All @@ -662,8 +674,14 @@ def _add_representation(
frame_end: Union[int, None] = None
files: Union[str, List[str]] = basename
if is_sequence:
# get only filtered files form dirname
files_from_dir = [
filename
for filename in os.listdir(dirname)
if filename.startswith(file_head)
]
# collect all data from dirname
cols, _ = clique.assemble(list(os.listdir(dirname)))
cols, _ = clique.assemble(files_from_dir)
if not cols:
raise CreatorError(
f"No collections found in directory '{dirname}'."
Expand Down

0 comments on commit 96e4269

Please sign in to comment.