Skip to content

Commit

Permalink
Merge pull request #73 from codeforIATI/70-fix-briefly-withdrawn
Browse files Browse the repository at this point in the history
Set country codes as withdrawn if specified in the source data
markbrough authored Nov 8, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
2 parents 5a76d6c + ce066b0 commit f79e67b
Showing 2 changed files with 15 additions and 4 deletions.
3 changes: 3 additions & 0 deletions importers/country.py
Original file line number Diff line number Diff line change
@@ -9,18 +9,21 @@ 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))
countries = [{
'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)
16 changes: 12 additions & 4 deletions importers/organisation_registration_agency.py
Original file line number Diff line number Diff line change
@@ -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")
pass

refresh_data()

0 comments on commit f79e67b

Please sign in to comment.