From 0a2d8efcd0d0b7164e91167d3a7adc2f011cea5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Du=C5=A1ek?= Date: Thu, 2 Sep 2021 11:19:17 +0200 Subject: [PATCH] improved version regex in path_info hook --- hooks/path_info.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/hooks/path_info.py b/hooks/path_info.py index 9448a09c..8baeb8cf 100644 --- a/hooks/path_info.py +++ b/hooks/path_info.py @@ -21,7 +21,7 @@ # this implementation assumes the version number is of the form 'v###' # coming just before an optional extension in the file/folder name and just # after a '.', '_', or '-'. -VERSION_REGEX = re.compile(r"(.*)([._-])v(\d+)\.?([^.]+)?$", re.IGNORECASE) +VERSION_REGEX = re.compile(r"(.*)([._-])v(\d+)[._-]*(.*)$", re.IGNORECASE) # a regular expression used to extract the frame number from the file. # this implementation assumes the version number is of the form '.####' @@ -69,8 +69,6 @@ def get_publish_name(self, path, sequence=False): filename = path_info["filename"] version_pattern_match = re.search(VERSION_REGEX, filename) - frame_pattern_match = re.search(FRAME_REGEX, filename) - if version_pattern_match: # found a version number, use the other groups to remove it prefix = version_pattern_match.group(1) @@ -79,7 +77,10 @@ def get_publish_name(self, path, sequence=False): publish_name = "%s.%s" % (prefix, extension) else: publish_name = prefix - elif frame_pattern_match and sequence: + filename = publish_name + + frame_pattern_match = re.search(FRAME_REGEX, filename) + if frame_pattern_match and sequence: # found a frame number, meplace it with #s prefix = frame_pattern_match.group(1) frame_sep = frame_pattern_match.group(2)