{ "info": { "author": "Tammo Ippen", "author_email": "tammo.ippen@posteo.de", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy" ], "description": "[![CircleCI](https://circleci.com/gh/tammoippen/iso4217parse.svg?style=svg)](https://circleci.com/gh/tammoippen/iso4217parse)\n[![Coverage Status](https://coveralls.io/repos/github/tammoippen/iso4217parse/badge.svg?branch=master)](https://coveralls.io/github/tammoippen/iso4217parse?branch=master)\n[![Tested CPython Versions](https://img.shields.io/badge/cpython-2.7%2C%203.5%2C%203.6%2C%203.7-brightgreen.svg)](https://img.shields.io/badge/cpython-2.7%2C%203.5%2C%203.6%2C%203.7-brightgreen.svg)\n[![Tested PyPy Versions](https://img.shields.io/badge/pypy-2.7--6.0.0%2C%203.5--6.0.0-brightgreen.svg)](https://img.shields.io/badge/pypy-2.7--6.0.0%2C%203.5--6.0.0-brightgreen.svg)\n[![PyPi version](https://img.shields.io/pypi/v/iso4217parse.svg)](https://pypi.python.org/pypi/iso4217parse)\n[![PyPi license](https://img.shields.io/pypi/l/iso4217parse.svg)](https://pypi.python.org/pypi/iso4217parse)\n\n# ISO4217 Currency Parser\n\nParse currencies (symbols and codes) from and to [ISO4217](https://en.wikipedia.org/wiki/ISO_4217).\n\nSimilar to [iso4217](https://github.com/spoqa/iso4217) package, but\n\n * data is aquired by scraping wikipedia (see [below](#data-aquisition)) - this is repeatable and you stay on the most current data\n * currency symbols are currated by hand - this allows some fuzzy currency matching\n * no download and parsing during install\n * no external dependancies (`enum34`)\n\nWhen you want to *reuse* the [*data.json*](https://github.com/tammoippen/iso4217parse/blob/master/iso4217parse/data.json) file for your projects, please leave a attribution note. I licence the file under (CC BY 4.0).\n\nInstall:\n```\npip install iso4217parse\n```\n\n## Documentation\n\nEach currency is modeled as a `collections.namedtuple`:\n```python\nCurrency = namedtuple('Currency', [\n 'alpha3', # unicode: the ISO4217 alpha3 code\n 'code_num', # int: the ISO4217 numeric code\n 'name', # unicode: the currency name\n 'symbols', # List[unicode]: list of possible symbols;\n # first is opinionated choice for representation\n 'minor', # int: number of decimal digits to round\n 'countries', # List[unicode]: list of countries that use this currency.\n])\n```\n\n**parse:** Try to parse the input in a best effort approach by using `by_alpha3()`, `by_code_num()`, ... functions:\n```python\nIn [1]: import iso4217parse\n\nIn [2]: iso4217parse.parse('CHF')\nOut[2]: [Currency(alpha3='CHF', code_num=756, name='Swiss franc',\n symbols=['SFr.', 'fr', 'Fr.', 'F', 'franc', 'francs', 'Franc', 'Francs'],\n minor=2, countries=['CH', 'LI'])]\n\nIn [3]: iso4217parse.parse(192)\nOut[3]:\n[Currency(alpha3='CUP', code_num=192, name='Cuban peso',\n symbols=['\u20b1', '\uff04', '\ufe69', '$', 'dollar', 'dollars', 'Dollar', 'Dollars', '\uff04MN', '\ufe69MN', '$MN'],\n minor=2, countries=['CU'])]\n\nIn [4]: iso4217parse.parse('Price is 5 \u20ac')\nOut[4]: [Currency(alpha3='EUR', code_num=978, name='Euro',\n symbols=['\u20ac', 'euro', 'euros'], minor=2,\n countries=['AD', 'AT', 'AX', 'BE', 'BL', 'CY', 'DE', 'EE', 'ES', 'FI',\n 'FR', 'GF', 'GP', 'GR', 'IE', 'IT', 'LT', 'LU', 'LV', 'MC',\n 'ME', 'MF', 'MQ', 'MT', 'NL', 'PM', 'PT', 'RE', 'SI', 'SK',\n 'SM', 'TF', 'VA', 'XK', 'YT'])]\n\nIn [5]: iso4217parse.parse('CA\ufe6915.76')\nOut[5]: [Currency(alpha3='CAD', code_num=124, name='Canadian dollar',\n symbols=['CA$', 'CA\uff04', '\uff04', '$', 'dollar', 'dollars', 'Dollar', 'Dollars', 'CA\ufe69', '\ufe69'],\n minor=2, countries=['CA'])]\n\nIn [6]: iso4217parse.parse?\nSignature: iso4217parse.parse(v, country_code=None)\nDocstring:\nTry parse `v` to currencies; filter by country_code\n\nIf `v` is a number, try `by_code_num()`; otherwise try:\n 1) if `v` is 3 character uppercase: `by_alpha3()`\n 2) Exact symbol match: `by_symbol()`\n 3) Exact country code match: `by_country()`\n 4) Fuzzy by symbol match heuristic: `by_symbol_match()`\n\nParameters:\n v: Union[unicode, int] Either a iso4217 numeric code or some string\n country_code: Optional[unicode] Iso3166 alpha2 country code.\n\nReturns:\n List[Currency]: found Currency objects.\n```\n\n**by_alpha3:** Get the currency by its iso4217 alpha3 code:\n```python\nIn [1]: import iso4217parse\n\nIn [2]: iso4217parse.by_alpha3('CHF')\nOut[2]: Currency(alpha3='CHF', code_num=756, name='Swiss franc',\n symbols=['SFr.', 'fr', 'Fr.', 'F', 'franc', 'francs', 'Franc', 'Francs'],\n minor=2, countries=['CH', 'LI'])\n\nIn [3]: iso4217parse.by_alpha3?\nSignature: iso4217parse.by_alpha3(code)\nDocstring:\nGet Currency for ISO4217 alpha3 code\n\nParameters:\n code: unicode An alpha3 iso4217 code.\n\nReturns:\n Currency: Currency object for `code`, if available.\n```\n\n**by_code_num:** Get the currency by its iso4217 numeric code:\n```python\nIn [1]: import iso4217parse\n\nIn [2]: iso4217parse.by_code_num(51)\nOut[2]: Currency(alpha3='AMD', code_num=51, name='Armenian dram',\n symbols=['\u058f', '\u0564\u0580', 'dram'], minor=2, countries=['AM'])\n\nIn [3]: iso4217parse.by_code_num?\nSignature: iso4217parse.by_code_num(code_num)\nDocstring:\nGet Currency for ISO4217 numeric code\n\nParameters:\n code_num: int An iso4217 numeric code.\n\nReturns:\n Currency: Currency object for `code_num`, if available.\n```\n\n**by_country:** Get currencies used in a country:\n```python\nIn [1]: import iso4217parse\n\nIn [2]: iso4217parse.country('HK')\nOut[2]:\n[\n Currency(alpha3='HKD', code_num=344, name='Hong Kong dollar',\n symbols=['HK$', 'HK\uff04', '\uff04', '$', 'dollar', 'dollars', 'Dollar', 'Dollars', 'HK\ufe69', '\ufe69', '\u5143'],\n minor=2, countries=['HK']),\n Currency(alpha3='CNH', code_num=None, name='Chinese yuan (when traded offshore)',\n symbols=['CN\u00a5', '\uffe5', 'CN\uffe5', '\u00a5', 'RMB', '\u5143'],\n minor=2, countries=['HK'])\n]\n\nIn [3]: iso4217parse.country?\nSignature: iso4217parse.by_country(country_code)\nDocstring:\nGet all currencies used in country\n\nParameters:\n country_code: unicode iso3166 alpha2 country code\n\nReturns:\n List[Currency]: Currency objects used in country.\n```\n\n**by_symbol:** Get currencies that use the given symbol:\n```python\nIn [1]: import iso4217parse\n\nIn [2]: iso4217parse.by_symbol('\uff04MN')\nOut[2]:\n[\n Currency(alpha3='CUP', code_num=192, name='Cuban peso',\n symbols=['\u20b1', '\uff04', '\ufe69', '$', 'dollar', 'dollars', 'Dollar', 'Dollars', '\uff04MN', '\ufe69MN', '$MN'],\n minor=2, countries=['CU'])\n]\n\nIn [3]: iso4217parse.by_symbol('\uff04')\nOut[3]: [...] # 35 different currencies\n\nIn [4]: [c.alpha3 for c in iso4217parse.by_symbol('\uff04')]\nOut[4]:\n['ARS', 'AUD', 'BBD', 'BMD', 'BZD', 'SBD', 'BND', 'CAD', 'CVE', 'KYD', 'CLP',\n 'COP', 'CUP', 'DOP', 'FJD', 'GYD', 'HKD', 'JMD', 'LRD', 'MXN', 'NAD', 'NZD',\n 'SGD', 'TTD', 'USD', 'UYU', 'TWD', 'CUC', 'ZWL', 'XCD', 'SRD', 'BRL', 'KID',\n 'NTD', 'TVD']\n\nIn [5]: iso4217parse.by_symbol('\uff04', country_code='US')\nOut[5]:\n[\n Currency(alpha3='USD', code_num=840, name='United States dollar',\n symbols=['US$', '$', '\uff04', '\ufe69', 'dollar', 'dollars', 'Dollar', 'Dollars', 'US\uff04', 'US\ufe69'],\n minor=2,\n countries=['AS', 'EC', 'GU', 'HT', 'MH', 'MP', 'PR', 'PW', 'SV', 'TC', 'TL', 'UM', 'US'])\n]\n\nIn [6]: iso4217parse.by_symbol?\nSignature: iso4217parse.by_symbol(symbol, country_code=None)\nDocstring:\nGet list of possible currencies for symbol; filter by country_code\n\nLook for all currencies that use the `symbol`. If there are currencies used\nin the country of `country_code`, return only those; otherwise return all\nfound currencies.\n\nParameters:\n symbol: unicode Currency symbol.\n country_code: Optional[unicode] Iso3166 alpha2 country code.\n\nReturns:\n List[Currency]: Currency objects for `symbol`; filter by country_code.\n```\n\n**by_symbol_match:** Look for currency symbol occurence in input string:\n```python\nIn [1]: import iso4217parse\n\nIn [2]: iso4217parse.by_symbol_match('RD$35.8')\nOut[2]:\n[\n Currency(alpha3='DOP', code_num=214, name='Dominican peso',\n symbols=['RD$', '\uff04', '\ufe69', '$', 'dollar', 'dollars', 'Dollar', 'Dollars', 'RD\uff04', 'RD\ufe69'],\n minor=2, countries=['DO'])\n]\n\nIn [3]: iso4217parse.by_symbol_match('The price is \u20a8 35.8 !')\nOut[3]:\n[\n Currency(alpha3='LKR', code_num=144, name='Sri Lankan rupee',\n symbols=['\u0dbb\u0dd4', '\u20a8', 'Rs', '\u0bb0\u0bc2', 'SLRs', 'rupees', 'rupee'],\n minor=2, countries=['LK']),\n Currency(alpha3='MUR', code_num=480, name='Mauritian rupee',\n symbols=['\u20a8', 'rupees', 'rupee'], minor=2, countries=['MU']),\n Currency(alpha3='NPR', code_num=524, name='Nepalese rupee',\n symbols=['\u0930\u0941', '\u20a8', 'Rs', 'Re', 'rupees', 'rupee'], minor=2, countries=['NP']),\n Currency(alpha3='PKR', code_num=586, name='Pakistani rupee',\n symbols=['\u20a8', 'Rs', 'rupees', 'rupee'],\n minor=2, countries=['PK'])\n]\n\nIn [4]: iso4217parse.by_symbol_match('The price is \u20a8 35.8 !', country_code='NP')\nOut[4]:\n[\n Currency(alpha3='NPR', code_num=524, name='Nepalese rupee',\n symbols=['\u0930\u0941', '\u20a8', 'Rs', 'Re', 'rupees', 'rupee'],\n minor=2, countries=['NP'])\n]\n\nIn [5]: iso4217parse.by_symbol_match?\nSignature: iso4217parse.by_symbol_match(value, country_code=None)\nDocstring:\nGet list of possible currencies where the symbol is in value; filter by country_code (iso3166 alpha2 code)\n\nLook for first matching currency symbol in `value`. Filter similar to `by_symbol`.\nSymbols are sorted by length and relevance of first character (see `_symbols()`).\n\nNote: This is a [heuristic](https://en.wikipedia.org/wiki/Heuristic) !\n\nParameters:\n value: unicode Some input string.\n country_code: Optional[unicode] Iso3166 alpha2 country code.\n\nReturns:\n List[Currency]: Currency objects found in `value`; filter by country_code.\n```\n\n\n## Data aquisition\n\nBasic ISO4217 currency information is gathered from wikipedia: https://en.wikipedia.org/wiki/ISO_4217 . The tables are parsed with `gen_data.py` and stored in `iso4217parse/data.json`. This gives information for `alpha3`, `code_num`, `name`, `minor` and `countries`. The currency symbol information is hand gathered from:\n\n* individuel wikipedia pages, i.e. [EUR](https://en.wikipedia.org/wiki/Euro) has a `Denominations` -> `Symbol` section.\n* http://www.iotafinance.com/en/ISO-4217-Currency-Codes.html\n* http://www.xe.com/currency/ , i.e. [GBP](http://www.xe.com/currency/gbp-british-pound) has a `Currency Facts` -> `Symbol` section\n\nand stored in `iso4217parse/symbols.json`. Each currency can have multiple currency symbols - the first symbol in the list is the (opinionated) choice\nfor the currency.\n\n**Contribution Note**: Possible ways to contribute here:\n\n* hand check symbols for currency code.\n* automatic generation of the `iso4217parse/symbols.json` file.\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/tammoippen/iso4217parse", "keywords": "iso4217,currency,parse,symbol", "license": "MIT", "maintainer": "Tammo Ippen", "maintainer_email": "tammo.ippen@posteo.de", "name": "iso4217parse", "package_url": "https://pypi.org/project/iso4217parse/", "platform": "", "project_url": "https://pypi.org/project/iso4217parse/", "project_urls": { "Homepage": "https://github.com/tammoippen/iso4217parse", "Repository": "https://github.com/tammoippen/iso4217parse" }, "release_url": "https://pypi.org/project/iso4217parse/0.5.1/", "requires_dist": null, "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*", "summary": "Parse currencies (symbols and codes) from and to ISO4217.", "version": "0.5.1" }, "last_serial": 4668534, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "fc6c0ca7c33ab9553313985afd330a95", "sha256": "64d469938d20f345042650dea94611419a5afd55cb6561d9e52d936774d15924" }, "downloads": -1, "filename": "iso4217parse-0.1.tar.gz", "has_sig": false, "md5_digest": "fc6c0ca7c33ab9553313985afd330a95", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 19683, "upload_time": "2017-10-10T14:24:15", "url": "https://files.pythonhosted.org/packages/c2/c8/8c5139b7b844834313a9edcf9f1798adffc8e538a27778a817eb55d64566/iso4217parse-0.1.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "1231e43e49ed8718b872d63afb73503a", "sha256": "19c7017773adfc3d50f72245b0b4a4ec4cc35ffcda697168b2e40e4ce7a3f4d0" }, "downloads": -1, "filename": "iso4217parse-0.2.tar.gz", "has_sig": false, "md5_digest": "1231e43e49ed8718b872d63afb73503a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 20176, "upload_time": "2017-10-10T14:54:41", "url": "https://files.pythonhosted.org/packages/3e/01/9126d6e8bea34f2286a67ecb4e9a41d0644e15ffd0bd631a44fe1ce51118/iso4217parse-0.2.tar.gz" } ], "0.3": [ { "comment_text": "", "digests": { "md5": "9b077063573f17edef9b82c08c89ffd2", "sha256": "1e9d136f28170d5d88ff5db6b62e9693e24e2fb85515b2108150630ab6505003" }, "downloads": -1, "filename": "iso4217parse-0.3.tar.gz", "has_sig": false, "md5_digest": "9b077063573f17edef9b82c08c89ffd2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 20305, "upload_time": "2017-10-11T16:24:13", "url": "https://files.pythonhosted.org/packages/19/d4/44d78a9d595d7c3a0865a4a30f2357060994dd7952dae827025393a6703d/iso4217parse-0.3.tar.gz" } ], "0.4": [ { "comment_text": "", "digests": { "md5": "3d300524b95d6e4634546b55ff72b23e", "sha256": "24c1ff6486eff3371bd46a9b1dcdbfa31c37090256d9602e48e3d9dadf7e2979" }, "downloads": -1, "filename": "iso4217parse-0.4.tar.gz", "has_sig": false, "md5_digest": "3d300524b95d6e4634546b55ff72b23e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 27717, "upload_time": "2018-09-25T09:44:14", "url": "https://files.pythonhosted.org/packages/e2/d8/f387b3b40bdc06d8764356f7b916e9c119a6adeb527a76f96833bac44dd5/iso4217parse-0.4.tar.gz" } ], "0.4.1": [ { "comment_text": "", "digests": { "md5": "8d92da3f140512c15eed6b6a000fd8e7", "sha256": "478816324b945f458732ea53e0198cf76696a0d6b6a8e6d205aaf7eaa0c5f1c8" }, "downloads": -1, "filename": "iso4217parse-0.4.1.tar.gz", "has_sig": false, "md5_digest": "8d92da3f140512c15eed6b6a000fd8e7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 27727, "upload_time": "2018-09-25T10:07:08", "url": "https://files.pythonhosted.org/packages/4f/85/1f434aba29aa86718756437519710fc4e53c55333d07831be0f22590e581/iso4217parse-0.4.1.tar.gz" } ], "0.4.2": [ { "comment_text": "", "digests": { "md5": "ed90ba830e092b7dfcf0b47913de9de4", "sha256": "c66da182854e18c1b34b1cdbb02f0fbb3fa6f2327a856185162a08b479e17523" }, "downloads": -1, "filename": "iso4217parse-0.4.2.tar.gz", "has_sig": false, "md5_digest": "ed90ba830e092b7dfcf0b47913de9de4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 27754, "upload_time": "2018-09-25T11:02:51", "url": "https://files.pythonhosted.org/packages/92/b6/3aabfef10dad7404c02acacbdd7ba680dc2feae970a2e5711c4f9823c2cb/iso4217parse-0.4.2.tar.gz" } ], "0.5.0": [ { "comment_text": "", "digests": { "md5": "4e34251c9e9300db773ef3dec9107c5b", "sha256": "328900dfe49888c9c886833062b440b3f7135d083b9e34aea2dad79b57aac54a" }, "downloads": -1, "filename": "iso4217parse-0.5.0.tar.gz", "has_sig": false, "md5_digest": "4e34251c9e9300db773ef3dec9107c5b", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*", "size": 20975, "upload_time": "2018-12-19T09:38:48", "url": "https://files.pythonhosted.org/packages/e2/e5/662d0aa584259ebad51fe1793fc8366a17de8277d3a2cba63d9d9b62b747/iso4217parse-0.5.0.tar.gz" } ], "0.5.1": [ { "comment_text": "", "digests": { "md5": "0fc34afc4f01be27278f9b2c48b5cbb9", "sha256": "16022eefde7d0648d20888661225e72cb3f67fbda8ab45bd634f696e12ffdfde" }, "downloads": -1, "filename": "iso4217parse-0.5.1.tar.gz", "has_sig": false, "md5_digest": "0fc34afc4f01be27278f9b2c48b5cbb9", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*", "size": 21017, "upload_time": "2019-01-07T13:14:45", "url": "https://files.pythonhosted.org/packages/7a/1d/5cfc7d59128bfa843187e93350e3ee98e09758feeea1c3138e1a7111ed0f/iso4217parse-0.5.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "0fc34afc4f01be27278f9b2c48b5cbb9", "sha256": "16022eefde7d0648d20888661225e72cb3f67fbda8ab45bd634f696e12ffdfde" }, "downloads": -1, "filename": "iso4217parse-0.5.1.tar.gz", "has_sig": false, "md5_digest": "0fc34afc4f01be27278f9b2c48b5cbb9", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*", "size": 21017, "upload_time": "2019-01-07T13:14:45", "url": "https://files.pythonhosted.org/packages/7a/1d/5cfc7d59128bfa843187e93350e3ee98e09758feeea1c3138e1a7111ed0f/iso4217parse-0.5.1.tar.gz" } ] }