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

Commit

Permalink
Avoid regex problem on Windows
Browse files Browse the repository at this point in the history
Don't include the directory path in the regex, because a pattern
starting with "C:\\Users" will result in:

re.error: incomplete escape \U at position 2

Instead, only do the regex on the filename part.
  • Loading branch information
dagewa committed Apr 17, 2024
1 parent 10b7715 commit fc5f8f4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/dxtbx/sequence_filenames.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,11 @@ def locate_files_matching_template_string(template):
matches = glob(template_string_to_glob_expr(template))
if template.count("#") != 1:
return matches
matches = [os.path.split(p) for p in matches]
i0, i1 = template_string_number_index(template)
prefix = template[:i0]
suffix = template[i1:]
patt = re.compile(prefix + "([^0]*)([0-9]+)" + suffix)
return [m for m in matches if patt.match(m)]
patt = re.compile("([^0]*)([0-9]+)" + suffix)
return [os.path.join(*m) for m in matches if patt.match(m[1])]


def template_image_range(template):
Expand Down

0 comments on commit fc5f8f4

Please sign in to comment.