Skip to content

Commit

Permalink
Set country codes as withdrawn if specified in the source data
Browse files Browse the repository at this point in the history
  • Loading branch information
markbrough committed Nov 8, 2023
1 parent 8c1fb17 commit 8375c81
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions importers/country.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 8375c81

Please sign in to comment.