Skip to main content

Lightweight ISO 4217 currency package

Project description

python-iso4217: fast currency data package for Python


This python package automatically updates its own currency data using github actions and immediately release new version of package with updates. So it's super fast and at the same time always contains fresh data.

Installation

Pip

pip install python-iso4217

Poetry

poetry add python-iso4217

Usage

from iso4217 import find_currency, iter_currency

# Filters that could be applied:
#   * currency_name
#   * alphabetical_code
#   * entity
#   * decimal_places
#   * numeric_code
#   * withdrawal_date
# The filters correspond to attributes of `Currency` class

# accept arbitrary filters as key/value pairs
currency = find_currency(currency_name="usd")

# if currency was not found, the lib will immediately raise CurrencyNotFoundError
defunct_currency = find_currency(currency_name="abc123")

# You need generator to lazy iter currencies? Ok

for c in iter_currency():
# do something

Advanced

Work with pydantic

import inspect

from iso4217 import Currency as _Currency, find_currency
from pydantic import BaseModel, root_validator, StrictInt


class Currency(BaseModel, _Currency):
    __root__: StrictInt

    @root_validator(skip_on_failure=True)
    def humanize(cls, values):
        currency_numeric_code: int = values.get("__root__")
        # inspect.getfullargspec(_Currency.__init__) will contain `self`, so we cut it off
        orig_currency_cls_dunder_init_arg_names = inspect.getfullargspec(_Currency.__init__).args[1:]
        currency = find_currency(numeric_code=currency_numeric_code)
        return {
            k: getattr(currency, k, None)
            for k in orig_currency_cls_dunder_init_arg_names
        }

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

python_iso4217-0.0.8.tar.gz (13.5 kB view details)

Uploaded Source

Built Distribution

python_iso4217-0.0.8-py3-none-any.whl (13.4 kB view details)

Uploaded Python 3

File details

Details for the file python_iso4217-0.0.8.tar.gz.

File metadata

  • Download URL: python_iso4217-0.0.8.tar.gz
  • Upload date:
  • Size: 13.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for python_iso4217-0.0.8.tar.gz
Algorithm Hash digest
SHA256 cdbb5cb5cc183182e97c9e110483e66b84abafbabbd0b91d8d1c64333f144a7e
MD5 022d51adcf3693b0c05c68aba14473af
BLAKE2b-256 c1ba323d961b3ef95b8c8e289dbee97b4c983ae4a92c189da7b9bea9462f65aa

See more details on using hashes here.

File details

Details for the file python_iso4217-0.0.8-py3-none-any.whl.

File metadata

File hashes

Hashes for python_iso4217-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 9df8257537eeb551587ba91f575e424c77d95e82a3a808fe7fb8356c7e4e0e9c
MD5 cdb5502d15cab3c57fdaf1780fdfdbfa
BLAKE2b-256 4f971916f2d68d336fe47e1b9ac19032cd006eb550a777d34c3b16442d23b74d

See more details on using hashes here.

Supported by

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