Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improved version regex in path_info hook #145

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions hooks/path_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 '.####'
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down