File tree Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -38,12 +38,12 @@ def get_visit_year(beamline, visit):
38
38
def get_xchem_subdirectory (visit ):
39
39
40
40
# This is the pattern all visits must have.
41
- pattern = r"^([a-z][a-z][0-9][0-9][0-9][0-9][0-9])[-]([0-9]+)$"
41
+ pattern = r"^([a-z][a-z][0-9][0-9][0-9][0-9][0-9])[-]([0-9]+)([_].*)? $"
42
42
43
43
match = re .search (pattern , visit )
44
44
45
45
if not match :
46
- raise RuntimeError (
46
+ raise ValueError (
47
47
f'the visit name "{ visit } " does not conform to the visit naming convention'
48
48
)
49
49
Original file line number Diff line number Diff line change @@ -29,20 +29,28 @@ async def _main_coroutine(
29
29
# Check valid visits.
30
30
assert get_xchem_subdirectory ("aa12345-1" ) == "aa12345/aa12345-1"
31
31
assert get_xchem_subdirectory ("aa12345-1234" ) == "aa12345/aa12345-1234"
32
+ assert get_xchem_subdirectory ("aa12345-1234_" ) == "aa12345/aa12345-1234"
33
+ assert (
34
+ get_xchem_subdirectory ("aa12345-1234_some stuff" ) == "aa12345/aa12345-1234"
35
+ )
32
36
33
37
# Check invalid visit formats.
34
- with pytest .raises (RuntimeError ) as excinfo :
38
+ with pytest .raises (ValueError ) as excinfo :
35
39
get_xchem_subdirectory ("aa12345" )
36
40
assert "convention" in str (excinfo .value )
37
41
38
- with pytest .raises (RuntimeError ) as excinfo :
42
+ with pytest .raises (ValueError ) as excinfo :
39
43
get_xchem_subdirectory ("a12345-1" )
40
44
assert "convention" in str (excinfo .value )
41
45
42
- with pytest .raises (RuntimeError ) as excinfo :
46
+ with pytest .raises (ValueError ) as excinfo :
43
47
get_xchem_subdirectory ("[aa12345-1]" )
44
48
assert "convention" in str (excinfo .value )
45
49
50
+ with pytest .raises (ValueError ) as excinfo :
51
+ get_xchem_subdirectory ("aa12345-1-somestuff" )
52
+ assert "convention" in str (excinfo .value )
53
+
46
54
# Check good directory.
47
55
parent = Path (output_directory ) / "processing/lab36"
48
56
full_path = parent / "aa12345/aa12345-1"
You can’t perform that action at this time.
0 commit comments