diff --git a/CHANGELOG.md b/CHANGELOG.md index 8fe3ca96..236a8b7a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## v2.0.1 - 2021-09-16 + +### Fixed + +- #79 - Fix `HtmlParserGTT1` regex parsing. + ## v2.0.0 - 2021-09-15 ### Added diff --git a/README.md b/README.md index 0eb3251e..57ce40b3 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,7 @@ The library is available as a Python package in pypi and can be installed with p ## Python Library ```python -from circuit_maintenance_parser import init_provider, init_data_raw +from circuit_maintenance_parser import init_provider, NotificationData raw_data = b"""BEGIN:VCALENDAR VERSION:2.0 @@ -99,7 +99,7 @@ END:VCALENDAR ntt_provider = init_provider("ntt") -data_to_process = init_data_raw("ical", raw_data) +data_to_process = NotificationData.init_from_raw("ical", raw_data) maintenances = ntt_provider.get_maintenances(data_to_process) diff --git a/circuit_maintenance_parser/parsers/gtt.py b/circuit_maintenance_parser/parsers/gtt.py index b6d217a6..c9a432db 100644 --- a/circuit_maintenance_parser/parsers/gtt.py +++ b/circuit_maintenance_parser/parsers/gtt.py @@ -30,18 +30,19 @@ def parse_tables(self, tables, data): # Group 1 matches the maintenance ID # Group 2 matches the status of the notification groups = re.search(r".+: ([0-9]+) - ([A-Z][a-z]+)", td_element.text.strip()) - data["maintenance_id"] = groups.groups()[0] - status = groups.groups()[1] - if status == "Reminder": - data["status"] = Status["CONFIRMED"] - elif status == "Update": - data["status"] = Status["RE_SCHEDULED"] - elif status == "Cancelled": - data["status"] = Status["CANCELLED"] - # When a email is cancelled there is no start or end time specificed - # Setting this to 0 and 1 stops any errors from pydantic - data["start"] = 0 - data["end"] = 1 + if groups: + data["maintenance_id"] = groups.groups()[0] + status = groups.groups()[1] + if status == "Reminder": + data["status"] = Status["CONFIRMED"] + elif status == "Update": + data["status"] = Status["RE_SCHEDULED"] + elif status == "Cancelled": + data["status"] = Status["CANCELLED"] + # When a email is cancelled there is no start or end time specificed + # Setting this to 0 and 1 stops any errors from pydantic + data["start"] = 0 + data["end"] = 1 elif "Start" in td_element.text: start = parser.parse(td_element.next_sibling.next_sibling.text) data["start"] = self.dt2ts(start) diff --git a/pyproject.toml b/pyproject.toml index 2894394d..ce3142f1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "circuit-maintenance-parser" -version = "2.0.0" +version = "2.0.1" description = "Python library to parse Circuit Maintenance notifications and return a structured data back" authors = ["Network to Code "] license = "Apache-2.0"