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

Commit

Permalink
handle lowered paths in representation files
Browse files Browse the repository at this point in the history
  • Loading branch information
iLLiCiTiT committed Jan 19, 2023
1 parent 813dc26 commit 281f8bc
Showing 1 changed file with 29 additions and 16 deletions.
45 changes: 29 additions & 16 deletions openpype/tools/push_to_project/control_integrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ def __init__(self, path, relative_path):
def __repr__(self):
return "<{}> '{}'".format(self.__class__.__name__, self.relative_path)

@property
def is_valid_file(self):
if not self.relative_path:
return False
return super(ResourceFile, self).is_valid_file


class ProjectPushItem:
def __init__(
Expand Down Expand Up @@ -333,6 +339,19 @@ def _clean_path(path):
new_value = new_value.replace("//", "/")
return new_value

@staticmethod
def _get_relative_path(path, src_dirpath):
dirpath, basename = os.path.split(path)
if not dirpath.lower().startswith(src_dirpath.lower()):
return None

relative_dir = dirpath[len(src_dirpath):].lstrip("/")
if relative_dir:
relative_path = "/".join([relative_dir, basename])
else:
relative_path = basename
return relative_path

@property
def frame(self):
"""First frame of representation files.
Expand Down Expand Up @@ -429,20 +448,16 @@ def _get_source_files_with_frames(self):
filepath = self._clean_path(
filepath_template.format(root=self._roots)
)

dirpath, basename = os.path.split(filepath_template)
if (
dirpath != src_dirpath
dirpath.lower() != src_dirpath.lower()
or not src_basename_regex.match(basename)
):
relative_dir = dirpath.replace(src_dirpath, "")
if relative_dir:
relative_path = "/".join([relative_dir, basename])
else:
relative_path = basename
relative_path = self._get_relative_path(filepath, src_dirpath)
resource_files.append(ResourceFile(filepath, relative_path))
continue

filepath = os.path.join(src_dirpath, basename)
frame = None
udim = None
for item in src_basename_regex.finditer(basename):
Expand Down Expand Up @@ -475,16 +490,14 @@ def _get_source_files(self):
filepath = self._clean_path(
filepath_template.format(root=self._roots))

if filepath_template == repre_path:
src_files.append(SourceFile(filepath))
if filepath_template.lower() == repre_path.lower():
src_files.append(
SourceFile(repre_path.format(root=self._roots))
)
else:
dirpath, basename = os.path.split(filepath_template)
relative_dir = dirpath.replace(src_dirpath, "")
if relative_dir:
relative_path = "/".join([relative_dir, basename])
else:
relative_path = basename

relative_path = self._get_relative_path(
filepath_template, src_dirpath
)
resource_files.append(
ResourceFile(filepath, relative_path)
)
Expand Down

0 comments on commit 281f8bc

Please sign in to comment.