generated from Hochfrequenz/python_template_repository
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
5,720 additions
and
44 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
File renamed without changes.
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 @@ | ||
"""contains model classes representing MIGs and AHBs""" |
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,21 @@ | ||
"""classes that represent MIGs""" | ||
|
||
from dataclasses import dataclass | ||
from datetime import date | ||
|
||
|
||
@dataclass(frozen=True, eq=True, order=True, unsafe_hash=True, kw_only=True) | ||
class MessageImplementationGuide: | ||
""" | ||
message implementation guide (MIG) | ||
""" | ||
|
||
veroeffentlichungsdatum: date | ||
""" | ||
publishing date | ||
""" | ||
autor: str | ||
"""author, most likely 'BDEW'""" | ||
|
||
versionsnummer: str | ||
"""e.g. '1.1c'""" |
File renamed without changes.
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,5 @@ | ||
"""classes for reading xml documents""" | ||
|
||
from .migreader import MigReader | ||
|
||
__all__ = ["MigReader"] |
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,53 @@ | ||
""" | ||
This a docstring for the module. | ||
""" | ||
|
||
import xml.etree.ElementTree as ET | ||
from datetime import date, datetime | ||
from pathlib import Path | ||
|
||
from bamx.models.messageimplementationguide import MessageImplementationGuide | ||
|
||
|
||
class MigReader: | ||
""" | ||
Accesses information from an XML based message implementation guide | ||
""" | ||
|
||
def __init__(self, xml_path: Path): | ||
""" | ||
initialize by providing the path to the XML file | ||
""" | ||
self._xml_path = xml_path | ||
self._element_tree = ET.parse(self._xml_path) | ||
|
||
def get_publishing_date(self) -> date: | ||
""" | ||
returns the publishing date of the message implementation guide | ||
""" | ||
raw_value = self._element_tree.getroot().attrib["Veroeffentlichungsdatum"] # e.g. '24.10.2023' | ||
result = datetime.strptime(raw_value, "%d.%m.%Y").date() | ||
return result | ||
|
||
def get_author(self) -> str: | ||
""" | ||
returns the author of the message implementation guide | ||
""" | ||
return self._element_tree.getroot().attrib["Author"] | ||
|
||
def get_version(self) -> str: | ||
""" | ||
returns the version of the message implementation guide | ||
""" | ||
return self._element_tree.getroot().attrib["Versionsnummer"] | ||
|
||
def read(self) -> MessageImplementationGuide: | ||
""" | ||
read the entire file and convert it to a MessageImplementationGuid instance | ||
""" | ||
result = MessageImplementationGuide( | ||
veroeffentlichungsdatum=self.get_publishing_date(), | ||
autor=self.get_author(), | ||
versionsnummer=self.get_version(), | ||
) | ||
return result |
This file was deleted.
Oops, something went wrong.
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,2 @@ | ||
The files in this directory have been copied from [the BDEW website](https://www.bdew.de/service/anwendungshilfen/edienergy-xml-beispieldateien/). | ||
The copyright remains with the BDEW. |
Oops, something went wrong.