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