mirror of
https://github.com/fhswf/aki_prj23_transparenzregister.git
synced 2025-04-24 21:32:33 +02:00
refactor: Resolve leftover todos
This commit is contained in:
parent
f9d3f0eb76
commit
982cbd7ad4
@ -126,7 +126,7 @@ if __name__ == "__main__":
|
||||
|
||||
missing_companies = (
|
||||
session.query(entities.MissingCompany)
|
||||
.where(entities.MissingCompany.searched_for is False)
|
||||
.where(entities.MissingCompany.searched_for == False) # noqa
|
||||
.all()
|
||||
)
|
||||
|
||||
|
@ -57,7 +57,6 @@ def determine_version(data: dict) -> BaseTransformer:
|
||||
module: Version module
|
||||
"""
|
||||
if "XJustiz_Daten" in data:
|
||||
# TODO consider class inheritance for version modules
|
||||
return v1.V1_Transformer()
|
||||
if "tns:nachrichtenkopf" in data[list(data.keys())[0]]:
|
||||
return v3.V3_Transformer()
|
||||
@ -79,14 +78,13 @@ def map_unternehmensregister_json(data: dict) -> Company:
|
||||
|
||||
if __name__ == "__main__":
|
||||
base_path = "./Jupyter/API-tests/Unternehmensregister/data/Unternehmensregister"
|
||||
# TODO Adapt to new structure with different versions
|
||||
for file in tqdm(glob.glob1(f"{base_path}/export", "*.json")):
|
||||
path = os.path.join(f"{base_path}/export", file)
|
||||
with open(path, encoding="utf-8") as file_object:
|
||||
try:
|
||||
company: Company = map_unternehmensregister_json(
|
||||
json.loads(file_object.read())
|
||||
)
|
||||
data = json.loads(file_object.read())
|
||||
transformer: BaseTransformer = determine_version(data)
|
||||
company: Company = transformer.map_unternehmensregister_json(data)
|
||||
|
||||
name = "".join(e for e in company.name if e.isalnum())[:50]
|
||||
|
||||
|
@ -435,7 +435,6 @@ class V1_Transformer(BaseTransformer): # noqa: N801
|
||||
"""
|
||||
result: dict = {"relationships": []}
|
||||
|
||||
# TODO Refactor mapping - this is a nightmare...
|
||||
result["id"] = self.map_company_id(data)
|
||||
result["name"] = self.name_from_beteiligung(data)
|
||||
|
||||
|
@ -526,7 +526,6 @@ class V3_Transformer(BaseTransformer): # noqa: N801
|
||||
path = ["tns:fachdatenRegister", "tns:auszug", "tns:letzteEintragung"]
|
||||
return traversal(data, path)
|
||||
|
||||
# TODO class model with inheritance - only difference: Determine root in __init__
|
||||
def map_unternehmensregister_json(self, data: dict) -> Company:
|
||||
"""Processes the Unternehmensregister structured export to a Company by using several helper methods.
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user