# Snatsch - ISO_3166, ISO_4217
A lightweight python library to retrieve countries and currencies based on ISO_3166-1 and ISO_4217 standards. This library was created despite of many others existing onces because it is lightweight, simple and easy to use.
## Getting Started
```bash
pip install snatsch-iso
```
## Usage
All ISO collections are parsed and structure on a standard way:
- Collection.get_all(): retrieve a list of instances
- Collection.search_keys(): provides a list of all possible keys that can be used for `search_by`
- Collection.search_by(): get a list of instances or a single instance that match the search criteria.
To retrieve information about any of the iso collection you can follow these examples:
```python
from iso import iso4217
# get a list of all Currencies
iso4217.Currencies.get_all()
[Currency(code='AED', num='784', d='2', currency='United Arab Emirates dirham', countries='United Arab Emirates'),
Currency(code='AFN', num='971', d='2', currency='Afghan afghani', countries='Afghanistan'),
Currency(code='ALL', num='8', d='2', currency='Albanian lek', countries='Albania'),
Currency(code='AMD', num='51', d='2', currency='Armenian dram', countries='Armenia'),
Currency(code='ANG', num='532', d='2', currency='Netherlands Antillean guilder', countries='Curaçao (CW), Sint Maarten (SX)'),
Currency(code='AOA', num='973', d='2', currency='Angolan kwanza', countries='Angola'),
Currency(code='ARS', num='32', d='2', currency='Argentine peso', countries='Argentina'),
Currency(code='AUD', num='36', d='2', currency='Australian dollar', countries='Australia, Christmas Island (CX), Cocos (Keeling) Islands (CC), Heard Island and McDonald Islands (HM), Kiribati (KI), Nauru (NR), Norfolk Island (NF), Tuvalu (TV)'),
Currency(code='AWG', num='533', d='2', currency='Aruban florin', countries='Aruba'),
Currency(code='AZN', num='944', d='2', currency='Azerbaijani manat', countries='Azerbaijan'),
. . .]
# get possible search keys
iso4217.Currencies.search_keys()
['code', 'num']
# get a Currency
iso4217.Currencies.search_by(code="BDT")
Currency(code='BDT', num='50', d='2', currency='Bangladeshi taka', countries='Bangladesh')
iso4217.Currencies.search_by(num="50")
Currency(code='BDT', num='50', d='2', currency='Bangladeshi taka', countries='Bangladesh')
```
Examples to retrieve information about countries:
```python
from iso import iso3166
# get a list of all Countries
iso3166.Countries.get_all()
[Country(name='Afghanistan', alpha2_code='AF', alpha3_code='AFG', num_code='4'),
Country(name='Åland Islands', alpha2_code='AX', alpha3_code='ALA', num_code='248'),
Country(name='Albania', alpha2_code='AL', alpha3_code='ALB', num_code='8'),
Country(name='Algeria', alpha2_code='DZ', alpha3_code='DZA', num_code='12'),
Country(name='American Samoa', alpha2_code='AS', alpha3_code='ASM', num_code='16'),
Country(name='Andorra', alpha2_code='AD', alpha3_code='AND', num_code='20'),
Country(name='Angola', alpha2_code='AO', alpha3_code='AGO', num_code='24'),
Country(name='Anguilla', alpha2_code='AI', alpha3_code='AIA', num_code='660'),
Country(name='Antarctica', alpha2_code='AQ', alpha3_code='ATA', num_code='10'),
Country(name='Antigua and Barbuda', alpha2_code='AG', alpha3_code='ATG', num_code='28'),
Country(name='Argentina', alpha2_code='AR', alpha3_code='ARG', num_code='32'),
Country(name='Armenia', alpha2_code='AM', alpha3_code='ARM', num_code='51'),
Country(name='Aruba', alpha2_code='AW', alpha3_code='ABW', num_code='533'),
Country(name='Australia', alpha2_code='AU', alpha3_code='AUS', num_code='36'),
Country(name='Austria', alpha2_code='AT', alpha3_code='AUT', num_code='40'),
Country(name='Azerbaijan', alpha2_code='AZ', alpha3_code='AZE', num_code='31'),
. . .]
# get all dominican republic subdivisions
iso3166.DOSubdivisions.get_all()
[Subdivision(code='DO-01', subdivision_name='Distrito Nacional (Santo Domingo)', subdivision_category='district', parent_subdivision='DO-40'),
Subdivision(code='DO-02', subdivision_name='Azua', subdivision_category='province', parent_subdivision='DO-41'),
Subdivision(code='DO-03', subdivision_name='Baoruco', subdivision_category='province', parent_subdivision='DO-38'),
Subdivision(code='DO-04', subdivision_name='Barahona', subdivision_category='province', parent_subdivision='DO-38'),
Subdivision(code='DO-05', subdivision_name='Dajabón', subdivision_category='province', parent_subdivision='DO-34'),
Subdivision(code='DO-06', subdivision_name='Duarte', subdivision_category='province', parent_subdivision='DO-33'),
Subdivision(code='DO-07', subdivision_name='Elías Piña', subdivision_category='province', parent_subdivision='DO-37'),
Subdivision(code='DO-08', subdivision_name='El Seibo', subdivision_category='province', parent_subdivision='DO-42'),
Subdivision(code='DO-09', subdivision_name='Espaillat', subdivision_category='province', parent_subdivision='DO-35'),
Subdivision(code='DO-10', subdivision_name='Independencia', subdivision_category='province', parent_subdivision='DO-38'),
Subdivision(code='DO-11', subdivision_name='La Altagracia', subdivision_category='province', parent_subdivision='DO-42'),
Subdivision(code='DO-12', subdivision_name='La Romana', subdivision_category='province', parent_subdivision='DO-42'),
Subdivision(code='DO-13', subdivision_name='La Vega', subdivision_category='province', parent_subdivision='DO-36'),
. . .]
# get all subdivisions that have a parent subdivision
iso3166.DOSubdivisions.search_by(parent_subdivision="DO-33")
[Subdivision(code='DO-06', subdivision_name='Duarte', subdivision_category='province', parent_subdivision='DO-33'),
Subdivision(code='DO-14', subdivision_name='María Trinidad Sánchez', subdivision_category='province', parent_subdivision='DO-33'),
Subdivision(code='DO-19', subdivision_name='Hermanas Mirabal', subdivision_category='province', parent_subdivision='DO-33'),
Subdivision(code='DO-20', subdivision_name='Samaná', subdivision_category='province', parent_subdivision='DO-33')]
```
## Tests
Run this command in the root of the project:
```bash
pytest -vv
```
## References:
- [ISO_3166-1](https://en.wikipedia.org/wiki/ISO_3166-1)
- [ISO_3166-2:DO](https://en.wikipedia.org/wiki/ISO_3166-2:DO)
- [ISO_4217](https://en.wikipedia.org/wiki/ISO_4217)
Raw data
{
"_id": null,
"home_page": "https://github.com/snatsch/python-iso",
"name": "snatsch-iso",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "iso iso4217 iso3166",
"author": "Victor Natschke",
"author_email": "vnatschke@gmail.com",
"download_url": "",
"platform": null,
"description": "# Snatsch - ISO_3166, ISO_4217\n\nA lightweight python library to retrieve countries and currencies based on ISO_3166-1 and ISO_4217 standards. This library was created despite of many others existing onces because it is lightweight, simple and easy to use.\n\n## Getting Started\n\n```bash\npip install snatsch-iso\n```\n\n## Usage\n\nAll ISO collections are parsed and structure on a standard way:\n\n- Collection.get_all(): retrieve a list of instances\n- Collection.search_keys(): provides a list of all possible keys that can be used for `search_by`\n- Collection.search_by(): get a list of instances or a single instance that match the search criteria.\n\nTo retrieve information about any of the iso collection you can follow these examples:\n\n```python\nfrom iso import iso4217\n\n# get a list of all Currencies\niso4217.Currencies.get_all()\n[Currency(code='AED', num='784', d='2', currency='United Arab Emirates dirham', countries='United Arab Emirates'),\n Currency(code='AFN', num='971', d='2', currency='Afghan afghani', countries='Afghanistan'),\n Currency(code='ALL', num='8', d='2', currency='Albanian lek', countries='Albania'),\n Currency(code='AMD', num='51', d='2', currency='Armenian dram', countries='Armenia'),\n Currency(code='ANG', num='532', d='2', currency='Netherlands Antillean guilder', countries='Cura\u00e7ao (CW), Sint Maarten (SX)'),\n Currency(code='AOA', num='973', d='2', currency='Angolan kwanza', countries='Angola'),\n Currency(code='ARS', num='32', d='2', currency='Argentine peso', countries='Argentina'),\n Currency(code='AUD', num='36', d='2', currency='Australian dollar', countries='Australia, Christmas Island (CX), Cocos (Keeling) Islands (CC), Heard Island and McDonald Islands (HM), Kiribati (KI), Nauru (NR), Norfolk Island (NF), Tuvalu (TV)'),\n Currency(code='AWG', num='533', d='2', currency='Aruban florin', countries='Aruba'),\n Currency(code='AZN', num='944', d='2', currency='Azerbaijani manat', countries='Azerbaijan'),\n . . .]\n\n # get possible search keys\niso4217.Currencies.search_keys()\n['code', 'num']\n\n# get a Currency\niso4217.Currencies.search_by(code=\"BDT\")\nCurrency(code='BDT', num='50', d='2', currency='Bangladeshi taka', countries='Bangladesh')\n\niso4217.Currencies.search_by(num=\"50\")\nCurrency(code='BDT', num='50', d='2', currency='Bangladeshi taka', countries='Bangladesh')\n```\n\nExamples to retrieve information about countries:\n\n```python\nfrom iso import iso3166\n\n# get a list of all Countries\niso3166.Countries.get_all()\n[Country(name='Afghanistan', alpha2_code='AF', alpha3_code='AFG', num_code='4'),\n Country(name='\u00c5land Islands', alpha2_code='AX', alpha3_code='ALA', num_code='248'),\n Country(name='Albania', alpha2_code='AL', alpha3_code='ALB', num_code='8'),\n Country(name='Algeria', alpha2_code='DZ', alpha3_code='DZA', num_code='12'),\n Country(name='American Samoa', alpha2_code='AS', alpha3_code='ASM', num_code='16'),\n Country(name='Andorra', alpha2_code='AD', alpha3_code='AND', num_code='20'),\n Country(name='Angola', alpha2_code='AO', alpha3_code='AGO', num_code='24'),\n Country(name='Anguilla', alpha2_code='AI', alpha3_code='AIA', num_code='660'),\n Country(name='Antarctica', alpha2_code='AQ', alpha3_code='ATA', num_code='10'),\n Country(name='Antigua and Barbuda', alpha2_code='AG', alpha3_code='ATG', num_code='28'),\n Country(name='Argentina', alpha2_code='AR', alpha3_code='ARG', num_code='32'),\n Country(name='Armenia', alpha2_code='AM', alpha3_code='ARM', num_code='51'),\n Country(name='Aruba', alpha2_code='AW', alpha3_code='ABW', num_code='533'),\n Country(name='Australia', alpha2_code='AU', alpha3_code='AUS', num_code='36'),\n Country(name='Austria', alpha2_code='AT', alpha3_code='AUT', num_code='40'),\n Country(name='Azerbaijan', alpha2_code='AZ', alpha3_code='AZE', num_code='31'),\n . . .]\n\n# get all dominican republic subdivisions\niso3166.DOSubdivisions.get_all()\n[Subdivision(code='DO-01', subdivision_name='Distrito Nacional (Santo Domingo)', subdivision_category='district', parent_subdivision='DO-40'),\n Subdivision(code='DO-02', subdivision_name='Azua', subdivision_category='province', parent_subdivision='DO-41'),\n Subdivision(code='DO-03', subdivision_name='Baoruco', subdivision_category='province', parent_subdivision='DO-38'),\n Subdivision(code='DO-04', subdivision_name='Barahona', subdivision_category='province', parent_subdivision='DO-38'),\n Subdivision(code='DO-05', subdivision_name='Dajab\u00f3n', subdivision_category='province', parent_subdivision='DO-34'),\n Subdivision(code='DO-06', subdivision_name='Duarte', subdivision_category='province', parent_subdivision='DO-33'),\n Subdivision(code='DO-07', subdivision_name='El\u00edas Pi\u00f1a', subdivision_category='province', parent_subdivision='DO-37'),\n Subdivision(code='DO-08', subdivision_name='El Seibo', subdivision_category='province', parent_subdivision='DO-42'),\n Subdivision(code='DO-09', subdivision_name='Espaillat', subdivision_category='province', parent_subdivision='DO-35'),\n Subdivision(code='DO-10', subdivision_name='Independencia', subdivision_category='province', parent_subdivision='DO-38'),\n Subdivision(code='DO-11', subdivision_name='La Altagracia', subdivision_category='province', parent_subdivision='DO-42'),\n Subdivision(code='DO-12', subdivision_name='La Romana', subdivision_category='province', parent_subdivision='DO-42'),\n Subdivision(code='DO-13', subdivision_name='La Vega', subdivision_category='province', parent_subdivision='DO-36'),\n . . .]\n\n# get all subdivisions that have a parent subdivision\niso3166.DOSubdivisions.search_by(parent_subdivision=\"DO-33\")\n[Subdivision(code='DO-06', subdivision_name='Duarte', subdivision_category='province', parent_subdivision='DO-33'),\n Subdivision(code='DO-14', subdivision_name='Mar\u00eda Trinidad S\u00e1nchez', subdivision_category='province', parent_subdivision='DO-33'),\n Subdivision(code='DO-19', subdivision_name='Hermanas Mirabal', subdivision_category='province', parent_subdivision='DO-33'),\n Subdivision(code='DO-20', subdivision_name='Saman\u00e1', subdivision_category='province', parent_subdivision='DO-33')]\n```\n\n## Tests\n\nRun this command in the root of the project:\n\n```bash\npytest -vv\n```\n\n## References:\n\n- [ISO_3166-1](https://en.wikipedia.org/wiki/ISO_3166-1)\n- [ISO_3166-2:DO](https://en.wikipedia.org/wiki/ISO_3166-2:DO)\n- [ISO_4217](https://en.wikipedia.org/wiki/ISO_4217)\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A lightweight python library to retrieve countries and currencies based on ISO_3166-1 and ISO_4217 standards.",
"version": "0.1.2",
"project_urls": {
"Homepage": "https://github.com/snatsch/python-iso"
},
"split_keywords": [
"iso",
"iso4217",
"iso3166"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "d858f6ab59a26e199dc6bbfd11764bb03ddead33207ad5a3b5b469ea13ed91cf",
"md5": "29ee40a03033160e0c4decedb432656d",
"sha256": "dc2a0a7a1841dbcaf5beae81abb3765b3bd1ba16f6b37ac83fb7ad0c5041d9e4"
},
"downloads": -1,
"filename": "snatsch_iso-0.1.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "29ee40a03033160e0c4decedb432656d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 14778,
"upload_time": "2024-01-12T20:46:01",
"upload_time_iso_8601": "2024-01-12T20:46:01.469517Z",
"url": "https://files.pythonhosted.org/packages/d8/58/f6ab59a26e199dc6bbfd11764bb03ddead33207ad5a3b5b469ea13ed91cf/snatsch_iso-0.1.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-01-12 20:46:01",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "snatsch",
"github_project": "python-iso",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "snatsch-iso"
}