Skip to content

Commit 94f919d

Browse files
authored
Merge pull request #79 from networktocode/kc_gtt_search_fix
Added regex search statement
2 parents 1ac13a2 + 8981287 commit 94f919d

File tree

1 file changed

+13
-12
lines changed
  • circuit_maintenance_parser/parsers

1 file changed

+13
-12
lines changed

circuit_maintenance_parser/parsers/gtt.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,19 @@ def parse_tables(self, tables, data):
3030
# Group 1 matches the maintenance ID
3131
# Group 2 matches the status of the notification
3232
groups = re.search(r".+: ([0-9]+) - ([A-Z][a-z]+)", td_element.text.strip())
33-
data["maintenance_id"] = groups.groups()[0]
34-
status = groups.groups()[1]
35-
if status == "Reminder":
36-
data["status"] = Status["CONFIRMED"]
37-
elif status == "Update":
38-
data["status"] = Status["RE_SCHEDULED"]
39-
elif status == "Cancelled":
40-
data["status"] = Status["CANCELLED"]
41-
# When a email is cancelled there is no start or end time specificed
42-
# Setting this to 0 and 1 stops any errors from pydantic
43-
data["start"] = 0
44-
data["end"] = 1
33+
if groups:
34+
data["maintenance_id"] = groups.groups()[0]
35+
status = groups.groups()[1]
36+
if status == "Reminder":
37+
data["status"] = Status["CONFIRMED"]
38+
elif status == "Update":
39+
data["status"] = Status["RE_SCHEDULED"]
40+
elif status == "Cancelled":
41+
data["status"] = Status["CANCELLED"]
42+
# When a email is cancelled there is no start or end time specificed
43+
# Setting this to 0 and 1 stops any errors from pydantic
44+
data["start"] = 0
45+
data["end"] = 1
4546
elif "Start" in td_element.text:
4647
start = parser.parse(td_element.next_sibling.next_sibling.text)
4748
data["start"] = self.dt2ts(start)

0 commit comments

Comments
 (0)