-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #282 from networktocode/release-v2.6.0
Release v2.6.0
- Loading branch information
Showing
23 changed files
with
1,013 additions
and
259 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
"""Windstream parser.""" | ||
import logging | ||
from datetime import timezone | ||
|
||
from circuit_maintenance_parser.parser import Html, Impact, CircuitImpact, Status | ||
from circuit_maintenance_parser.utils import convert_timezone | ||
|
||
# pylint: disable=too-many-nested-blocks, too-many-branches | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class HtmlParserWindstream1(Html): | ||
"""Notifications Parser for Windstream notifications.""" | ||
|
||
def parse_html(self, soup): | ||
"""Execute parsing.""" | ||
data = {} | ||
data["circuits"] = [] | ||
impact = Impact("NO-IMPACT") | ||
confirmation_words = [ | ||
"Demand Maintenance Notification", | ||
"Planned Maintenance Notification", | ||
"Emergency Maintenance Notification", | ||
] | ||
cancellation_words = ["Postponed Maintenance Notification", "Cancelled Maintenance Notification"] | ||
|
||
h1_tag = soup.find("h1") | ||
if h1_tag.string.strip() == "Completed Maintenance Notification": | ||
data["status"] = Status("COMPLETED") | ||
elif any(keyword in h1_tag.string.strip() for keyword in confirmation_words): | ||
data["status"] = Status("CONFIRMED") | ||
elif h1_tag.string.strip() == "Updated Maintenance Notification": | ||
data["status"] = Status("RE-SCHEDULED") | ||
elif any(keyword in h1_tag.string.strip() for keyword in cancellation_words): | ||
data["status"] = Status("CANCELLED") | ||
|
||
div_tag = h1_tag.find_next_sibling("div") | ||
summary_text = div_tag.get_text(separator="\n", strip=True) | ||
summary_text = summary_text.split("\nDESCRIPTION OF MAINTENANCE")[0] | ||
|
||
data["summary"] = summary_text | ||
|
||
table = soup.find("table") | ||
for row in table.find_all("tr"): | ||
if len(row) < 2: | ||
continue | ||
cols = row.find_all("td") | ||
header_tag = cols[0].string | ||
if header_tag is None or header_tag == "Maintenance Address:": | ||
continue | ||
header_tag = header_tag.string.strip() | ||
value_tag = cols[1].string.strip() | ||
if header_tag == "WMT:": | ||
data["maintenance_id"] = value_tag | ||
elif "Date & Time:" in header_tag: | ||
dt_time = convert_timezone(value_tag) | ||
if "Event Start" in header_tag: | ||
data["start"] = int(dt_time.replace(tzinfo=timezone.utc).timestamp()) | ||
elif "Event End" in header_tag: | ||
data["end"] = int(dt_time.replace(tzinfo=timezone.utc).timestamp()) | ||
elif header_tag == "Outage": | ||
impact = Impact("OUTAGE") | ||
else: | ||
continue | ||
|
||
table = soup.find("table", "circuitTable") | ||
for row in table.find_all("tr"): | ||
cols = row.find_all("td") | ||
if len(cols) == 9: | ||
if cols[0].string.strip() == "Name": | ||
continue | ||
data["account"] = cols[0].string.strip() | ||
data["circuits"].append(CircuitImpact(impact=impact, circuit_id=cols[2].string.strip())) | ||
|
||
return [data] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,7 @@ | |
from circuit_maintenance_parser.parsers.telstra import HtmlParserTelstra1, HtmlParserTelstra2 | ||
from circuit_maintenance_parser.parsers.turkcell import HtmlParserTurkcell1 | ||
from circuit_maintenance_parser.parsers.verizon import HtmlParserVerizon1 | ||
from circuit_maintenance_parser.parsers.windstream import HtmlParserWindstream1 | ||
from circuit_maintenance_parser.parsers.zayo import HtmlParserZayo1, SubjectParserZayo1 | ||
from circuit_maintenance_parser.processor import CombinedProcessor, GenericProcessor, SimpleProcessor | ||
from circuit_maintenance_parser.utils import rgetattr | ||
|
@@ -150,22 +151,38 @@ def get_maintenances(self, data: NotificationData) -> Iterable[Maintenance]: | |
@classmethod | ||
def get_default_organizer(cls) -> str: | ||
"""Expose default_organizer as class attribute.""" | ||
return cls._default_organizer.get_default() # type: ignore | ||
try: | ||
return cls._default_organizer.get_default() # type: ignore | ||
except AttributeError: | ||
# TODO: This exception handling is required for Pydantic 1.x compatibility. To be removed when the dependency is deprecated. | ||
return cls._default_organizer | ||
|
||
@classmethod | ||
def get_default_processors(cls) -> List[GenericProcessor]: | ||
"""Expose default_processors as class attribute.""" | ||
return cls._processors.get_default() # type: ignore | ||
try: | ||
return cls._processors.get_default() # type: ignore | ||
except AttributeError: | ||
# TODO: This exception handling is required for Pydantic 1.x compatibility. To be removed when the dependency is deprecated. | ||
return cls._processors | ||
|
||
@classmethod | ||
def get_default_include_filters(cls) -> Dict[str, List[str]]: | ||
"""Expose include_filter as class attribute.""" | ||
return cls._include_filter.get_default() # type: ignore | ||
try: | ||
return cls._include_filter.get_default() # type: ignore | ||
except AttributeError: | ||
# TODO: This exception handling is required for Pydantic 1.x compatibility. To be removed when the dependency is deprecated. | ||
return cls._include_filter | ||
|
||
@classmethod | ||
def get_default_exclude_filters(cls) -> Dict[str, List[str]]: | ||
"""Expose exclude_filter as class attribute.""" | ||
return cls._exclude_filter.get_default() # type: ignore | ||
try: | ||
return cls._exclude_filter.get_default() # type: ignore | ||
except AttributeError: | ||
# TODO: This exception handling is required for Pydantic 1.x compatibility. To be removed when the dependency is deprecated. | ||
return cls._exclude_filter | ||
|
||
@classmethod | ||
def get_extended_data(cls): | ||
|
@@ -307,10 +324,13 @@ class GTT(GenericProvider): | |
"""EXA (formerly GTT) provider custom class.""" | ||
|
||
# "Planned Work Notification", "Emergency Work Notification" | ||
_include_filter = PrivateAttr({EMAIL_HEADER_SUBJECT: ["Work Notification"]}) | ||
_include_filter = PrivateAttr( | ||
{"Icalendar": ["BEGIN"], "ical": ["BEGIN"], EMAIL_HEADER_SUBJECT: ["Work Notification"]} | ||
) | ||
|
||
_processors: List[GenericProcessor] = PrivateAttr( | ||
[ | ||
SimpleProcessor(data_parsers=[ICal]), | ||
CombinedProcessor(data_parsers=[EmailDateParser, HtmlParserGTT1]), | ||
] | ||
) | ||
|
@@ -449,6 +469,17 @@ class Verizon(GenericProvider): | |
_default_organizer = PrivateAttr("[email protected]") | ||
|
||
|
||
class Windstream(GenericProvider): | ||
"""Windstream provider custom class.""" | ||
|
||
_processors: List[GenericProcessor] = PrivateAttr( | ||
[ | ||
CombinedProcessor(data_parsers=[EmailDateParser, HtmlParserWindstream1]), | ||
] | ||
) | ||
_default_organizer = PrivateAttr("[email protected]") | ||
|
||
|
||
class Zayo(GenericProvider): | ||
"""Zayo provider custom class.""" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.