mirror of
https://github.com/fhswf/aki_prj23_transparenzregister.git
synced 2025-04-24 16:52:34 +02:00
refactor(data-extraction): Improve variable naming and exception handling
This commit is contained in:
parent
4e25be5466
commit
d6223b4192
@ -123,7 +123,7 @@ class PersonToCompanyRelationship(CompanyRelationship):
|
||||
class CompanyToCompanyRelationship(CompanyRelationship):
|
||||
"""Extension of CompanyRelationship with extras for Company."""
|
||||
|
||||
description: str
|
||||
name: str
|
||||
|
||||
|
||||
class FinancialKPIEnum(Enum):
|
||||
|
@ -4,6 +4,7 @@ import glob
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
from datetime import datetime
|
||||
|
||||
import xmltodict
|
||||
@ -62,9 +63,9 @@ def parse_stakeholder(data: dict) -> CompanyRelationship | None:
|
||||
if data["Beteiligter"]["Natuerliche_Person"]["Voller_Name"]["Vorname"] is None:
|
||||
return CompanyToCompanyRelationship(
|
||||
**{
|
||||
"description": data["Beteiligter"]["Natuerliche_Person"][
|
||||
"Voller_Name"
|
||||
]["Nachname"],
|
||||
"name": data["Beteiligter"]["Natuerliche_Person"]["Voller_Name"][
|
||||
"Nachname"
|
||||
],
|
||||
"location": Location(
|
||||
**{
|
||||
"city": data["Beteiligter"]["Natuerliche_Person"][
|
||||
@ -127,7 +128,7 @@ def parse_stakeholder(data: dict) -> CompanyRelationship | None:
|
||||
"role": RelationshipRoleEnum(
|
||||
data["Rolle"]["Rollenbezeichnung"]["content"]
|
||||
),
|
||||
"description": data["Beteiligter"]["Organisation"]["Bezeichnung"][
|
||||
"name": data["Beteiligter"]["Organisation"]["Bezeichnung"][
|
||||
"Bezeichnung_Aktuell"
|
||||
],
|
||||
"location": Location(
|
||||
@ -324,7 +325,7 @@ def map_business_purpose(data: dict) -> str | None:
|
||||
return data["XJustiz_Daten"]["Fachdaten_Register"]["Basisdaten_Register"][
|
||||
"Gegenstand_oder_Geschaeftszweck"
|
||||
]
|
||||
except Exception:
|
||||
except KeyError:
|
||||
return None
|
||||
|
||||
|
||||
@ -491,7 +492,6 @@ if __name__ == "__main__":
|
||||
json.dump(
|
||||
dataclasses.asdict(company), export_file, ensure_ascii=False
|
||||
)
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
logger.error(f"Error in processing {path}")
|
||||
logger.error(e)
|
||||
break
|
||||
sys.exit(1)
|
||||
|
@ -51,7 +51,7 @@ def test_parse_stakeholder_org_hidden_in_person() -> None:
|
||||
}
|
||||
expected_result = CompanyToCompanyRelationship(
|
||||
role=RelationshipRoleEnum.KOMMANDITIST, # type: ignore
|
||||
description="Some Company KG",
|
||||
name="Some Company KG",
|
||||
type=CompanyRelationshipEnum.COMPANY,
|
||||
location=Location(**{"city": "Area 51"}),
|
||||
)
|
||||
@ -96,7 +96,7 @@ def test_parse_stakeholder_org() -> None:
|
||||
"Rolle": {"Rollenbezeichnung": {"content": "Geschäftsführender Direktor"}},
|
||||
}
|
||||
expected_result = CompanyToCompanyRelationship(
|
||||
description="Transparenzregister kG",
|
||||
name="Transparenzregister kG",
|
||||
role=RelationshipRoleEnum.DIREKTOR, # type: ignore
|
||||
type=CompanyRelationshipEnum.COMPANY,
|
||||
location=Location(
|
||||
|
Loading…
x
Reference in New Issue
Block a user