pycountry icon indicating copy to clipboard operation
pycountry copied to clipboard

Match data files to iso-codes?

Open QuLogic opened this issue 8 months ago • 2 comments

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 avatar Dec 12 '23 07:12 QuLogic

@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?

nschimmoller avatar Dec 12 '23 17:12 nschimmoller

I think @llimeht articulated it clearer than I could in https://github.com/pycountry/pycountry/issues/188#issuecomment-1869800053

QuLogic avatar Jan 29 '24 00:01 QuLogic