diff --git a/openpype/hosts/flame/api/lib.py b/openpype/hosts/flame/api/lib.py index b963a1cb39..1e444f3b40 100644 --- a/openpype/hosts/flame/api/lib.py +++ b/openpype/hosts/flame/api/lib.py @@ -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