lists.arthurdejong.org
RSS feed

python-stdnum branch master updated. 1.17-60-gf691bf7

[Date Prev][Date Next] [Thread Prev][Thread Next]

python-stdnum branch master updated. 1.17-60-gf691bf7



This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "python-stdnum".

The branch, master has been updated
       via  f691bf749a541033fe38b42742dda1d00e006d87 (commit)
      from  5cdef0d2b7df30441e128cd2b7510979efd12e0e (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://arthurdejong.org/git/python-stdnum/commit/?id=f691bf749a541033fe38b42742dda1d00e006d87

commit f691bf749a541033fe38b42742dda1d00e006d87
Author: Arthur de Jong <arthur@arthurdejong.org>
Date:   Sun Nov 13 19:52:31 2022 +0100

    Update German OffeneRegister lookup data format
    
    It appears that the data structure at OffeneRegister has changed which
    requires a different query. Data is returned in a different structure.

diff --git a/stdnum/de/handelsregisternummer.py 
b/stdnum/de/handelsregisternummer.py
index 5e90c78..0cc2947 100644
--- a/stdnum/de/handelsregisternummer.py
+++ b/stdnum/de/handelsregisternummer.py
@@ -332,16 +332,17 @@ def check_offeneregister(number, timeout=30):  # pragma: 
no cover (not part of n
     It will contain something like the following::
 
         {
-            'retrieved_at': '2018-06-24T12:34:53Z',
-            'native_company_number': 'The number requested',
-            'company_number': 'Compact company number',
-            'registrar': 'Registar',
-            'federal_state': 'State name',
-            'registered_office': 'Office',
-            'register_art': 'Register type',
-            'register_nummer': 'Number'
-            'name': 'The name of the organisation',
-            'current_status': 'currently registered',
+            'companyId': 'U1206_HRB14011',
+            'courtCode': 'U1206',
+            'courtName': 'Chemnitz',
+            'globalId': 'sn_293298',
+            'isCurrent': 'True',
+            'name': 'Internet hier GmbH Presentation Provider',
+            'nativeReferenceNumber': 'Chemnitz HRB 14011',
+            'referenceNumberFirstSeen': '2020-06-12',
+            'stdRefNo': 'U1206_HRB14011',
+            'validFrom': '2020-06-12',
+            'validTill': '',
         }
 
     Will return None if the number is invalid or unknown.
@@ -350,27 +351,17 @@ def check_offeneregister(number, timeout=30):  # pragma: 
no cover (not part of n
     # network access for the tests and unnecessarily load the web service
     import requests
     court, registry, number, qualifier = _split(number)
-    # First lookup the registrar code
-    # (we could look up the number by registrar (court), registry and number
-    # but it seems those queries are too slow)
     response = requests.get(
         _offeneregister_url,
         params={
-            'sql': 'select company_number from company where registrar = :p0 
limit 1',
-            'p0': court},
-        timeout=timeout)
-    response.raise_for_status()
-    try:
-        registrar = response.json()['rows'][0][0].split('_')[0]
-    except (KeyError, IndexError) as e:  # noqa: F841
-        raise InvalidComponent()  # unknown registrar code
-    # Lookup the number
-    number = '%s_%s%s' % (registrar, registry, number)
-    response = requests.get(
-        _offeneregister_url,
-        params={
-            'sql': 'select * from company where company_number = :p0 limit 1',
-            'p0': number},
+            'sql': '''
+                   select *
+                   from ReferenceNumbers
+                   join Names on ReferenceNumbers.companyId = Names.companyId
+                   where nativeReferenceNumber = :p0
+                   limit 1
+                   ''',
+            'p0': '%s %s %s' % (court, registry, number)},
         timeout=timeout)
     response.raise_for_status()
     try:
diff --git a/tests/test_de_handelsregisternummer.py 
b/tests/test_de_handelsregisternummer.py
index 496c356..aa1473a 100644
--- a/tests/test_de_handelsregisternummer.py
+++ b/tests/test_de_handelsregisternummer.py
@@ -41,7 +41,7 @@ class TestOffeneRegister(unittest.TestCase):
         result = handelsregisternummer.check_offeneregister('Chemnitz HRB 
14011')
         self.assertTrue(all(
             key in result.keys()
-            for key in ['company_number', 'current_status', 'federal_state', 
'registrar', 'native_company_number']))
+            for key in ['companyId', 'courtCode', 'courtName', 'name', 
'nativeReferenceNumber']))
         # Test invalid number
         result = handelsregisternummer.check_offeneregister('Chemnitz HRA 
14012')
         self.assertIsNone(result)

-----------------------------------------------------------------------

Summary of changes:
 stdnum/de/handelsregisternummer.py     | 47 ++++++++++++++--------------------
 tests/test_de_handelsregisternummer.py |  2 +-
 2 files changed, 20 insertions(+), 29 deletions(-)


hooks/post-receive
-- 
python-stdnum