Skip to main content

Return useful information for every country in the ISO 3166 standard.

Project description

Country Data Management

A Python package for managing and retrieving country-related data, including country information, subdivisions, and translated country names.

Features

  • Retrieve country data using ISO country codes
  • Access country subdivisions (states, provinces, etc.)
  • Get translated country names in different languages
  • Handle data from JSON files stored in a structured directory format

Installation

pip install country-registry

Usage

Initialize the Client

from country_registry import CountryRegistry

client = CountryRegistry()

Get Country Data

from country_registry import CountryRegistry

client = CountryRegistry()
# Get data for a specific country using ISO code
country_data = client.get_country_data_by_code("US")

Get Subdivisions

from country_registry import CountryRegistry

client = CountryRegistry()

# Get all subdivisions for a country as list
subdivisions = client.get_country_subdivisions_by_code("US")

# Get a specific subdivision by code
subdivision = client.get_country_subdivision_by_codes("US", "CA")

Get Translations

from country_registry import CountryRegistry

client = CountryRegistry()

# Get all country names in a specific language
spanish_names = client.get_translated_countries_names_by_lang_code("es")

# Get a specific country name in a language
spanish_name = client.get_translated_country_name_by_codes("es", "US")

Data Format

TODO add data format here

Error Handling

The package includes robust error handling:

  • Returns None for non-existent country codes
  • Returns None for non-existent subdivision codes
  • Returns empty list [] for countries without subdivisions
  • Returns empty dict {} for missing translation files
  • Logs errors using the loguru logger

Dependencies

  • Python 3.6+
  • loguru
  • pathlib

License

MIT License

Copyright (c) 2024

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

country_registry-0.1.1.tar.gz (2.5 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

country_registry-0.1.1-py3-none-any.whl (2.9 MB view details)

Uploaded Python 3

File details

Details for the file country_registry-0.1.1.tar.gz.

File metadata

  • Download URL: country_registry-0.1.1.tar.gz
  • Upload date:
  • Size: 2.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.0

File hashes

Hashes for country_registry-0.1.1.tar.gz
Algorithm Hash digest
SHA256 1bcf4cb23fbd587e0efe31ff8da367bb3bf722d29292f223cb5594f2bae0ca0b
MD5 275bdd2f735eb844164ad938180860cf
BLAKE2b-256 77e2b6363f0d375f33a78bccf97a0cc1185c4fd0c257bdfb361b62f748b81f53

See more details on using hashes here.

File details

Details for the file country_registry-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for country_registry-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b9e80058863fe6e441fd3730820a27ea97d4f0f2e5d8a9b7ed5ae5ce2a7f95e2
MD5 18089ef949907fda9ea1999572921330
BLAKE2b-256 9a8070d348461157ef36d1a48264a52b41d9b96d1add604ddbecd91b0e2f9f21

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page