Skip to content

Commit

Permalink
makes visit patern case insensitive
Browse files Browse the repository at this point in the history
  • Loading branch information
David Erb committed May 11, 2023
1 parent 8a5852a commit 416913a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/dls_utilpack/visit.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def get_visit_year(beamline, visit):
def get_xchem_subdirectory(visit):

# This is the pattern all visits must have.
pattern = r"^([a-z][a-z][0-9][0-9][0-9][0-9][0-9])[-]([0-9]+)([_].*)?$"
pattern = r"^([A-Za-z][A-Za-z][0-9][0-9][0-9][0-9][0-9])[-]([0-9]+)([_].*)?$"

match = re.search(pattern, visit)

Expand All @@ -47,8 +47,8 @@ def get_xchem_subdirectory(visit):
f'the visit name "{visit}" does not conform to the visit naming convention'
)

part1 = match.group(1)
part2 = match.group(2)
part1 = match.group(1).lower()
part2 = match.group(2).lower()

subdirectory = f"{part1}/{part1}-{part2}"

Expand Down
3 changes: 3 additions & 0 deletions tests/test_visit.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ async def _main_coroutine(

# Check valid visits.
assert get_xchem_subdirectory("aa12345-1") == "aa12345/aa12345-1"
assert get_xchem_subdirectory("AB12345-1") == "ab12345/ab12345-1"
assert get_xchem_subdirectory("Ab12345-1") == "ab12345/ab12345-1"
assert get_xchem_subdirectory("aB12345-1") == "ab12345/ab12345-1"
assert get_xchem_subdirectory("aa12345-1234") == "aa12345/aa12345-1234"
assert get_xchem_subdirectory("aa12345-1234_") == "aa12345/aa12345-1234"
assert (
Expand Down

0 comments on commit 416913a

Please sign in to comment.