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.2.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.2-py3-none-any.whl (2.9 MB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: country_registry-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 3243ce836cdbf2233b31cd4570f14dac64cee2c16f9a59075181166edb36bd71
MD5 f93587f36e7af18dab05da8563770cf2
BLAKE2b-256 d9b1b3ccadd5c1a781d1b4fe9709dd0041d78cb30ecd342e3076a7a0009eb1ca

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for country_registry-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2a7ed114a03e630c24aced39f5d51cd4f3111bd665d386a3aa805e1299802374
MD5 0f9f7b8df84bc39dcdd83bf28ad6608c
BLAKE2b-256 7c090450a4ac853a7abf4e3e6b4fe9a39dc396c158dcd43a800d7383ab33f873

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