From 8375c81a503bd3c2932a1831615f80ca5a5e6b61 Mon Sep 17 00:00:00 2001 From: Mark Brough Date: Wed, 8 Nov 2023 16:55:18 +0100 Subject: [PATCH 1/3] Set country codes as withdrawn if specified in the source data --- importers/country.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/importers/country.py b/importers/country.py index 5021048..1141d35 100644 --- a/importers/country.py +++ b/importers/country.py @@ -9,6 +9,7 @@ def run(): ('code', 'code'), ('name_en', 'name_en'), ('name_fr', 'name_fr'), + ('@status', 'status'), ] r = fetch(url) reader = csv.DictReader(r.iter_lines(decode_unicode=True)) @@ -16,11 +17,13 @@ def run(): 'code': x['code'], 'name_en': x['name_en'], 'name_fr': x['name_fr'], + 'status': 'active' if x.get('active') == 'True' else 'withdrawn', } for x in reader] countries.append({ 'code': 'XK', 'name_en': 'Kosovo', 'name_fr': '', + 'status': 'active' }) countries = sorted(countries, key=lambda x: x['name_en']) Importer('Country', 'countries', lookup, source_data=countries) From 3a3dee65c2f3bbd23094ad87e66b0a75c5fa8b74 Mon Sep 17 00:00:00 2001 From: Mark Brough Date: Wed, 8 Nov 2023 17:03:31 +0100 Subject: [PATCH 2/3] Handle org-id.guide exception for now --- importers/organisation_registration_agency.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/importers/organisation_registration_agency.py b/importers/organisation_registration_agency.py index de2b9fc..708af43 100644 --- a/importers/organisation_registration_agency.py +++ b/importers/organisation_registration_agency.py @@ -1,5 +1,7 @@ from time import sleep +from requests.exceptions import HTTPError + from .helpers import Importer, fetch @@ -10,10 +12,16 @@ def refresh_data(): # # For more details, see: # https://github.com/OpenDataServices/org-ids/issues/256 - refresh_url = 'https://org-id.guide/_update_lists' - for x in range(6): - fetch(refresh_url) - sleep(0.5) + + try: + refresh_url = 'https://org-id.guide/_update_lists' + for x in range(6): + fetch(refresh_url) + sleep(0.5) + except HTTPError as exception: + if exception.response.status_code == 500: + print("Unable to ensure that org-id.guide is providing the latest data") + continue refresh_data() From ce066b07946508540d50cfda9c1ccf430123da30 Mon Sep 17 00:00:00 2001 From: Mark Brough Date: Wed, 8 Nov 2023 17:05:13 +0100 Subject: [PATCH 3/3] Fix typo --- importers/organisation_registration_agency.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/importers/organisation_registration_agency.py b/importers/organisation_registration_agency.py index 708af43..2c9d727 100644 --- a/importers/organisation_registration_agency.py +++ b/importers/organisation_registration_agency.py @@ -21,7 +21,7 @@ def refresh_data(): except HTTPError as exception: if exception.response.status_code == 500: print("Unable to ensure that org-id.guide is providing the latest data") - continue + pass refresh_data()