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 countries-data

Usage

Initialize the Client

from country_registry import CountryRegistry

country_registry = CountryRegistry()

Get Country Data

from country_registry import CountryRegistry

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

Get Subdivisions

from country_registry import CountryRegistry

country_registry = CountryRegistry()

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

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

Get Translations

from country_registry import CountryRegistry

country_registry = CountryRegistry()

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

# Get a specific country name in a language
spanish_name = country_registry.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.0.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.0-py3-none-any.whl (2.9 MB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: country_registry-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 13be72029434b574a7ea9e2f8ca967c456ef35c5905cc9b84bc45df70bb301a4
MD5 aba99c13ecf739693fead47cea94c08b
BLAKE2b-256 ca196ded693f4ff4d4e1363b3851b76168b9141f0ef4432f5abbd8297fcc30a2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for country_registry-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 96f91d8ca5e8f2f87f66ce8bff7566e13576eef1424b5a0a211ae4a04fb1533f
MD5 35686d2eb34e38a0e40b7cc5c9af0672
BLAKE2b-256 d628b58363cd320bed996ce663da90b6139591e2590b129049b70d10070f8faf

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