Skip to content

Commit 4c38b04

Browse files
committed
Expand and clean up regexes
1 parent fde2bb7 commit 4c38b04

File tree

1 file changed

+32
-22
lines changed

1 file changed

+32
-22
lines changed

mazevo_r25/management/commands/r25_mazevo.py

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -33,34 +33,44 @@
3333
INFO 201 A /AUT25 Large Lecture
3434
MUSEN 350/550/AUT25 Large Lecture # No section!
3535
STAT/SOC/CS&SS 221 /AUT25 Large Lecture # No section!
36+
STAT/SOC /CS&SS 221 / WIN26 Large Lect # extra space in currics
3637
"""
37-
3838
event_pat = re.compile(
3939
r"""
40-
^ # start at beginning
41-
(?:\*?) # optional asterisk (why?)
42-
(?P<exam>EXAM:\*?\ )? # it's an exam, and another asterisk?
43-
(?P<curric>[A-Z &]+) # curric abbrev, can contain space, &
44-
(?:\/[A-Z &]+)* # additional currics, separated by slashes
45-
[ ] # space separator
46-
(?P<number>\d{3}) # course number, 3 digits
47-
(?:\/\d{3})* # additional numbers, separated by slashes
48-
[ ]* # optional space separator
49-
(?P<section>\w{0,2}) # section, 1 or 2 letters
50-
# rest is ignored
40+
^ # start at beginning
41+
(?:\*?) # optional asterisk
42+
(?P<exam>EXAM:\*?\ )? # it's an exam, and another asterisk?
43+
(?P<curric>[A-Z &]+?) # curric abbrev, can contain space, &
44+
(?:\ ?\/ # slash separator, maybe an extra space
45+
(?P<curric2>[A-Z &]+?))? # second curric
46+
(?:\ ?\/ # slash separator, maybe an extra space
47+
(?P<curric3>[A-Z &]+?))? # third curric
48+
[ ] # space separator
49+
(?P<number>\d{3}) # course number, 3 digits
50+
(?:\/ # slash separator
51+
(?P<number2>\d{3}))? # second number
52+
[ ]* # optional space separator
53+
(?P<section>\w{0,2}) # section, 1 or 2 letters, or absent
54+
# rest is ignored
5155
""", re.VERBOSE)
5256

57+
"""
5358
# some room names to match
54-
# 'BAG 260'
55-
# 'HST T568'
56-
# 'SWS 026-030'
57-
room_pat = re.compile(r"""
58-
^ # start at beginning
59-
(?P<building>[A-Z]+[0-9]?)\s+ # building code
60-
(?P<room>[A-Z]?\d{2,3}[A-Z]?) # room number
61-
(?:-.*)? # room "extension"
62-
$ # end at end
63-
""", re.VERBOSE)
59+
BAG 260
60+
HST T568
61+
SWS 026-030
62+
CSE2 G20
63+
GNOMS060
64+
"""
65+
room_pat = re.compile(
66+
r"""
67+
^ # start at beginning
68+
(?P<building>[A-Z0-9]{,4}?) # building code, 4 chars or less
69+
[ ]* # optional space separator
70+
(?P<room>[A-Z]?\d{2,3}[A-Z]?) # room number, 2 or 3 digits
71+
(?:-.*)? # combined room number, ignore it
72+
$ # end at end
73+
""", re.VERBOSE)
6474

6575

6676
class Command(BaseCommand):

0 commit comments

Comments
 (0)