Skip to content

Commit

Permalink
🧙‍♀️ Initial Setup
Browse files Browse the repository at this point in the history
  • Loading branch information
hf-kklein committed May 23, 2024
1 parent e423661 commit 51ec125
Show file tree
Hide file tree
Showing 16 changed files with 5,720 additions and 44 deletions.
16 changes: 8 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[project]
name = "your-favourite-package-name"
description = "Description of your package"
name = "bamx"
description = "Python interface XML documents for MIG and AHBs, published by BDEW "
license = { text = "MIT" }
requires-python = ">=3.11"
authors = [{ name = "your name", email = "your@email.address" }]
keywords = ["your", "important", "keywords"]
authors = [{ name = "Hochfrequenz Unternehmensberatung GmbH", email = "info+github@hochfrequenz.de" }]
keywords = ["BDEW", "XML", "AHB", "MIG", "Marktkommunikation"]
classifiers = [
"Development Status :: 4 - Beta",
"Environment :: Console",
Expand All @@ -20,8 +20,8 @@ dependencies = [] # add all the dependencies here
dynamic = ["readme", "version"]

[project.urls]
Changelog = "https://github.com/Hochfrequenz/python_template_repository/releases"
Homepage = "https://github.com/Hochfrequenz/python_template_repository"
Changelog = "https://github.com/Hochfrequenz/bdew_ahb_mig_xml-python/releases"
Homepage = "https://github.com/Hochfrequenz/bdew_ahb_mig_xml-python"

[tool.black]
line-length = 120
Expand All @@ -38,7 +38,7 @@ max-line-length = 120
truethy-bool = true

[tool.mypy]
disable_error_code = ["no-untyped-def", "no-untyped-call"]
disable_error_code = []

[build-system]
requires = ["hatchling>=1.8.0", "hatch-vcs", "hatch-fancy-pypi-readme"]
Expand All @@ -52,7 +52,7 @@ fragments = [{ path = "README.md" }]
source = "vcs"

[tool.hatch.build.hooks.vcs]
version-file = "src/_your_package_version.py"
version-file = "src/_bamx_version.py"
template = '''
version = "{version}"
'''
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions src/bamx/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""contains model classes representing MIGs and AHBs"""
21 changes: 21 additions & 0 deletions src/bamx/models/messageimplementationguide.py
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.
5 changes: 5 additions & 0 deletions src/bamx/reader/__init__.py
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"]
53 changes: 53 additions & 0 deletions src/bamx/reader/migreader.py
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
23 changes: 0 additions & 23 deletions src/mypackage/mymodule.py

This file was deleted.

4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ deps =
# add your fixtures like e.g. pytest_datafiles here
setenv = PYTHONPATH = {toxinidir}/src
commands =
pylint mypackage
pylint bamx
pylint unittests --rcfile=unittests/.pylintrc
# add single files (ending with .py) or packages here

Expand All @@ -37,7 +37,7 @@ deps =
{[testenv:tests]deps}
-r dev_requirements/requirements-type_check.txt
commands =
mypy --show-error-codes src/mypackage --strict
mypy --show-error-codes src/bamx --strict
mypy --show-error-codes unittests --strict
# add single files (ending with .py) or packages here

Expand Down
2 changes: 2 additions & 0 deletions unittests/example_files/README.md
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.
Loading

0 comments on commit 51ec125

Please sign in to comment.