Firmenbuch (JustizOnline HVD): register numbers and politicians' company functions

- firmenbuch.search: register number for companies linked to people/parties, only for
  one current register entry with the same name
- firmenbuch.extracts: current extracts; officers/shareholders who are politicians in
  the database (exact birth date + name, new person hint birth_date) become company_role
  claims; nobody else is stored, raw responses are not archived, addresses never read;
  the register's daily change list triggers re-extracts
- enrich.firmenbuch closes roles a newer extract no longer lists
- Request.data (raw body, part of the fingerprint); SOAP faults are not retried
- firmenbuch_number drops leading zeros; migration 0009 adds company_role and aligns
  stored numbers; internal politrack_org ids are no longer stored as identifiers
- company_role in API types, MCP docs, person money tab, connections, labels

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
simonandClaude Opus 5.5 committed 2026-11-19 11:33:01 +01:00
1 parent 68be25a953
commit 10c677ca70
30 files changed
+597 -20

No files matched your search

+8 -2
View File
@@ -30,6 +30,11 @@ log = logging.getLogger(__name__)
RETRY_STATUS = {429, 500, 502, 503, 504}
def is_soap_fault(resp: httpx.Response) -> bool:
"""A SOAP service answers a bad request with HTTP 500 and a Fault body; retrying can't change the answer."""
return resp.status_code == 500 and b"Fault>" in resp.content[:4000]
class Disallowed(Exception):
"""robots.txt forbids fetching this URL."""
@@ -121,14 +126,15 @@ class Fetcher:
for attempt in range(attempts):
self._throttle(req.url, spec)
try:
resp = self.client.request(req.method, req.url, params=req.params, json=req.json, headers=headers)
resp = self.client.request(req.method, req.url, params=req.params, json=req.json, content=req.data,
headers=headers)
except httpx.TransportError as exc:
if attempt == attempts - 1:
raise
log.warning("transport error %s (%s), retrying", req.url, exc)
time.sleep(min(5 * 2 ** attempt, 120))
continue
if resp.status_code in RETRY_STATUS and attempt < attempts - 1:
if resp.status_code in RETRY_STATUS and attempt < attempts - 1 and not is_soap_fault(resp):
retry_after = resp.headers.get("Retry-After", "")
time.sleep(min(float(retry_after) if retry_after.isdigit() else 5 * 2 ** attempt, 300))
continue