flame: rename path to fname

https://github.com/pypeclub/OpenPype/pull/2519#discussion_r785974817
This commit is contained in:
Jakub Jezek 2022-01-19 14:23:54 +01:00
parent 226903ea0b
commit ff76b5c3d9
No known key found for this signature in database
GPG key ID: D8548FBF690B100A

View file

@ -601,12 +601,12 @@ def get_clips_in_reels(project):
return output_clips
def get_reformated_path(path, padded=True):
def get_reformated_path(fname, padded=True):
"""
Return fixed python expression path
Args:
path (str): path url or simple file name
fname (str): file name
Returns:
type: string with reformated path
@ -615,27 +615,27 @@ def get_reformated_path(path, padded=True):
get_reformated_path("plate.1001.exr") > plate.%04d.exr
"""
padding = get_padding_from_path(path)
found = get_frame_from_path(path)
padding = get_padding_from_path(fname)
found = get_frame_from_path(fname)
if not found:
log.info("Path is not sequence: {}".format(path))
return path
log.info("File name is not sequence: {}".format(fname))
return fname
if padded:
path = path.replace(found, "%0{}d".format(padding))
fname = fname.replace(found, "%0{}d".format(padding))
else:
path = path.replace(found, "%d")
fname = fname.replace(found, "%d")
return path
return fname
def get_padding_from_path(path):
def get_padding_from_path(fname):
"""
Return padding number from Flame path style
Args:
path (str): path url or simple file name
fname (str): file name
Returns:
int: padding number
@ -644,20 +644,17 @@ def get_padding_from_path(path):
get_padding_from_path("plate.0001.exr") > 4
"""
found = get_frame_from_path(path)
found = get_frame_from_path(fname)
if found:
return len(found)
else:
return None
return len(found) if found else None
def get_frame_from_path(path):
def get_frame_from_path(fname):
"""
Return sequence number from Flame path style
Args:
path (str): path url or simple file name
fname (str): file name
Returns:
int: sequence frame number
@ -669,9 +666,6 @@ def get_frame_from_path(path):
"""
frame_pattern = re.compile(r"[._](\d+)[.]")
found = re.findall(frame_pattern, path)
found = re.findall(frame_pattern, fname)
if found:
return found.pop()
else:
return None
return found.pop() if found else None