Subdivision lookup fails if item has multiple names
Hello, thanks for your work on this project.
I encountered this while doing a lookup by name for subdivision Wales (GB-WLS).
The subdivision is present in the database but has the name Wales; Cymru.
Should the alternative names perhaps be stored in other fields?
I am pretty perplexed but actually, with the current version, there seems to be no wales at all!:
>>> import pycountry
>>> for region in list(pycountry.subdivisions):
... if "Wales".lower() in region.name.lower() or "WLS" in region.code.upper():
... print(region.code, region.name)
...
AU-NSW New South Wales
My version:
# dnf info python3-pycountry |grep -E '(Version|Release)'
Version : 22.3.5
Release : 1.fc36
I wonder wheter this can be because of a database of my distribution? Or is the database included in pycountry?
EDIT: Well, it's even worse than that. Neither Wales, Scotland nor England show up in either pycountry.countries nor pycountry.subdivisions. Quite the omission!
>>> pycountry.subdivisions.lookup('england')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.10/site-packages/pycountry/db.py", line 39, in load_if_needed
return f(self, *args, **kw)
File "/usr/lib/python3.10/site-packages/pycountry/db.py", line 147, in lookup
raise LookupError("Could not find a record for %r" % value)
LookupError: Could not find a record for 'england'
>>> pycountry.countries.lookup('england')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.10/site-packages/pycountry/db.py", line 39, in load_if_needed
return f(self, *args, **kw)
File "/usr/lib/python3.10/site-packages/pycountry/db.py", line 147, in lookup
raise LookupError("Could not find a record for %r" % value)
LookupError: Could not find a record for 'england'
EDIT2: This is probably due to the recent changes in iso3316-2 relating to moving the countries of Great Britain to different levels.
@jac32 and @js-9 you are correct this was a transitory issue with the Debian package where we get country data from. It is fixed as of 23.12.7