{ "info": { "author": "Raphael Ritz", "author_email": "raphael.ritz@incf.org", "bugtrack_url": null, "classifiers": [ "Programming Language :: Python", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "=================\nincf.countryutils\n=================\n\n`incf.countryutils` provides a convenience API on top of\na list of countries by continent (data_file) as found on Wikipedia_\n(a copy is included in the distribution).\n\nIt supports transformations between the different types of country\ncodes and names like in:\n\n >>> from incf.countryutils import transformations\n >>> transformations.cca2_to_ccn('de')\n '276'\n >>> transformations.ccn_to_cn(276)\n 'Germany'\n\nCountry codes supported are *numeric* (`ccn`; internal reference format),\n*two letter country codes* (`cca2`), and *three letter country codes* (`cca3`).\nIn addition, `incf.countryutils` knows the *simple English name* of each\ncountry (`cn`) as well as the *official English name*. \n\nTransformation names follow the pattern `_to_` where `f1` and `f2`\nrefer to country codes or names. All transformations to and from the reference\nformat (`ccn`) are provided.\n\nWhen providing a numeric country code as an argument integer as well as\nstring representations are accepted.\n\nMoreover, there are some combined transformations available for convenience.\nMost notably this is _to_:\n\n >>> transformations.cc_to_cn('FR')\n 'France'\n >>> transformations.cc_to_cn('FRa')\n 'France'\n >>> transformations.cc_to_cn('250')\n 'France'\n >>> transformations.cc_to_cn(250)\n 'France'\n >>> transformations.cc_to_con(250)\n 'French Republic France'\n\nLookup by name is only supported for the simple English name:\n\n >>> transformations.cn_to_ccn('Italy')\n '380'\n >>> transformations.ccn_to_con('380')\n 'Italian Republic Italy'\n\n\nContinents\n==========\n\nBased on the data from Wikipedia_ `incf.countryutils` allows looking \nup the continent a country belongs to (`ctn`: continent name; \n`ctca2`: two letter continent code):\n\n >>> transformations.cn_to_ctn('Italy')\n 'Europe'\n >>> transformations.cca_to_ctn('us')\n 'North America'\n\nContinents have two letter codes as well like in:\n\n >>> transformations.cca_to_ctca2('usa')\n 'NA'\n\nGiven a continent, one can obtain its constituent countries:\n\n >>> transformations.ctca2_to_ccn('AN')\n ['010', '074', '260', '334', '239']\n\n\nAlternative API (OO)\n====================\n\nThere is an alternative, more object-oriented API based on the\nnotion of `Country` and `Continent` types. On creation, a country \nor continent needs to be passed a name or code:\n\n >>> from incf.countryutils.datatypes import Country\n >>> china = Country('China')\n >>> china\n \n\nThe country's names and codes are available as attributes:\n\n >>> china.name\n 'China'\n >>> china.official_name\n \"People's Republic of China\"\n >>> china.numeric\n '156'\n >>> china.alpha2\n 'CN'\n >>> china.alpha3\n 'CHN'\n\nand the `continent` property refers to a corresponding `Continent` \ninstance:\n\n >>> china.continent\n \n\nwhich in turn has the following attributes:\n\n >>> china.continent.name\n 'Asia'\n >>> china.continent.alpha2\n 'AS'\n\nAsking a continent for its constituent countries returns\na generator object returning country instances in turn:\n\n >>> china.continent.countries\n \n >>> china.continent.countries.next()\n \n >>> [c.name for c in china.continent.countries]\n ['Afghanistan', 'Armenia', 'Azerbaijan', 'Bahrain', ...]\n\n\n\nRelated packages\n================\n\nThe use case driving the development of this package has been the\nwish to be able to get at a continent given a country where the \ncountry can be specified in any ISO 3166 compliant way. \n\nThere is also pycountry_ which handles also regional subdivision,\ncurrency, and language. It may also gain the capabilities provided\nhere but note that pycountry_ requires lxml_ which may not always\nbe readily available on some platforms. \n\nFinally, for those interested in looking up countries by IP address\nthere is ip2cc_. \n\n\n\n.. _Wikipedia: http://en.wikipedia.org/wiki/List_of_countries_by_continent_(data_file)\n.. _pycountry: http://pypi.python.org/pypi/pycountry\n\n.. _lxml: http://pypi.python.org/pypi/lxml\n\n.. _ip2cc: http://pypi.python.org/pypi/ip2cc\n\nChangelog\n=========\n\n1.0 - (2009-04-20)\n------------------\n\n* Initial release", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "UNKNOWN", "keywords": "Python 'ISO 3166' 'country codes'", "license": "BSD", "maintainer": null, "maintainer_email": null, "name": "incf.countryutils", "package_url": "https://pypi.org/project/incf.countryutils/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/incf.countryutils/", "project_urls": { "Download": "UNKNOWN", "Homepage": "UNKNOWN" }, "release_url": "https://pypi.org/project/incf.countryutils/1.0/", "requires_dist": null, "requires_python": null, "summary": "A convenience API for transformations between different ISO 3166 country codes.", "version": "1.0" }, "last_serial": 833376, "releases": { "1.0": [ { "comment_text": "", "digests": { "md5": "cb0d2d8ad9ce5a0c77dc1c63eefc7c46", "sha256": "7d76e72203f4b13838880ab1418bf51ecc4eaca73d102fc5dd7114e4f1e3064b" }, "downloads": -1, "filename": "incf.countryutils-1.0.tar.gz", "has_sig": false, "md5_digest": "cb0d2d8ad9ce5a0c77dc1c63eefc7c46", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 21629, "upload_time": "2009-04-20T17:26:51", "url": "https://files.pythonhosted.org/packages/a8/88/2b08c961935a9fe00b00a4e1b53b81758771da142a5900cc8c9d28d79f9d/incf.countryutils-1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "cb0d2d8ad9ce5a0c77dc1c63eefc7c46", "sha256": "7d76e72203f4b13838880ab1418bf51ecc4eaca73d102fc5dd7114e4f1e3064b" }, "downloads": -1, "filename": "incf.countryutils-1.0.tar.gz", "has_sig": false, "md5_digest": "cb0d2d8ad9ce5a0c77dc1c63eefc7c46", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 21629, "upload_time": "2009-04-20T17:26:51", "url": "https://files.pythonhosted.org/packages/a8/88/2b08c961935a9fe00b00a4e1b53b81758771da142a5900cc8c9d28d79f9d/incf.countryutils-1.0.tar.gz" } ] }