pycountry
pycountry copied to clipboard
Match data files to iso-codes?
In iso-codes
, the data files are named with an iso_
prefix, but here the files have an iso
prefix (i.e., no underscore).
Downstream, we would like to replace these files with unbundled ones. Debian does this using this patch, and I ported it to Fedora for my use.
However, given the mention of gettext.translation
in tests, the new check via importlib.resources
, and the mention of iso3166.mo
->iso3166-1.mo
, I wonder if the file names are part of the expected API of pycountry
? If that is the case, I wonder if it would be possible to rename the files to match iso-codes
upstream (i.e., iso###.json
-> iso_###.json
, etc.)?
@QuLogic
- New importlib.resources check was added to make sure that ModuleNotFoundError is properly raised. Mainly added to reach required code coverage in pytest configuration
# We prioritise importing the backported `importlib_resources`
# because the function we use (`importlib.resources.files`) is only
# available from Python 3.9, but the module itself exists since 3.7.
# We install `importlib_resources` on Python < 3.9.
# TODO: Remove usage of importlib_resources once support for Python 3.8 is dropped
try:
import importlib_resources # type: ignore
except ModuleNotFoundError:
from importlib import resources as importlib_resources
- File names are part of the expected API of pycountry
- Yes the file names are part of the expected API of pycountry
I'm very clear on the ask here and implementation seems straightforward which I appreciate. I''m not sure I understand the use case / need. Are you able to provide more context?
I think @llimeht articulated it clearer than I could in https://github.com/pycountry/pycountry/issues/188#issuecomment-1869800053