okay fine

This commit is contained in:
pacnpal
2024-11-03 17:47:26 +00:00
parent 01c6004a79
commit 27eb239e97
10020 changed files with 1935769 additions and 2364 deletions

View File

@@ -0,0 +1,46 @@
COPYRIGHT (c) 2008 - 2023, pycountry
Pycountry is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or any later version.
This project is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
Contributors:
- Christian Theune (2008-2020, 2022)
- Nate Schimmoller (2022-2023)
- Zachary Ware (2016, 2023)
- Alan Orth (2023)
- Ashok Argent-Katwala (2020)
- Bastien Vallet (2020)
- Chris R Bunney 2020
- Christian Zagrodnick (2012-2013)
- Christoph Zwerschke (2013)
- Jakub Wilk (2020)
- Janis Kirsteins (2019)
- Justin Ryan Wagner 2014
- Kevin Deldycke (2014, 2016)
- Louis Sautier (2020)
- Lucas Wiman (2015)
- Mario Vilas (2014)
- Michael Howitz (2020)
- Michał Bielawski (2021, 2023)
- Michał Górny (2020)
- Mike Taves (2023)
- Pedro Ferreira (2013)
- Stuart Prescott (2021)
- Victor Mireyev (2016)
- simon klemenc (2016)
Additional Acknowledgements and Licensing Information:
- Data in the /src/databases/ and /src/locales/ folders is sourced from the Debian iso-codes project, available at: https://salsa.debian.org/iso-codes-team/iso-codes. This data is used under the terms of the GNU Lesser General Public License Version 2.1 (February 1999).
The Debian iso-codes project is a collection of code lists for different standards, maintained and made available under the GNU Lesser General Public License Version 2.1. We gratefully acknowledge the Debian iso-codes team and contributors for their work and for making this resource freely available.
The full text of the GNU Lesser General Public License Version 2.1 can be found at: https://salsa.debian.org/iso-codes-team/iso-codes/-/blob/main/COPYING.
For the full text of the GNU Lesser General Public License,
see https://github.[AWS-SECRET-REMOVED]E.txt.

View File

@@ -0,0 +1,303 @@
"""pycountry"""
import os.path
import unicodedata
from importlib import metadata as _importlib_metadata
from typing import Dict, List, Optional, Type
import pycountry.db
# We prioritise importing the backported `importlib_resources`
# because the function we use (`importlib.resources.files`) is only
# available from Python 3.9, but the module itself exists since 3.7.
# We install `importlib_resources` on Python < 3.9.
# TODO: Remove usage of importlib_resources once support for Python 3.8 is dropped
try:
import importlib_resources # type: ignore
except ModuleNotFoundError:
from importlib import resources as importlib_resources # type: ignore
def resource_filename(package_or_requirement: str, resource_name: str) -> str:
return str(
importlib_resources.files(package_or_requirement) / resource_name
)
def get_version(distribution_name: str) -> Optional[str]:
try:
return _importlib_metadata.version(distribution_name)
except _importlib_metadata.PackageNotFoundError:
return "n/a"
# Variable annotations
LOCALES_DIR: str = resource_filename("pycountry", "locales")
DATABASE_DIR: str = resource_filename("pycountry", "databases")
__version__: Optional[str] = get_version("pycountry")
def remove_accents(input_str: str) -> str:
output_str = input_str
if not input_str.isascii():
# Borrowed from https://stackoverflow.com/a/517974/1509718
nfkd_form = unicodedata.normalize("NFKD", input_str)
output_str = "".join(
[c for c in nfkd_form if not unicodedata.combining(c)]
)
return output_str
class ExistingCountries(pycountry.db.Database):
"""Provides access to an ISO 3166 database (Countries)."""
data_class = pycountry.db.Country
root_key = "3166-1"
def search_fuzzy(self, query: str) -> List[Type["ExistingCountries"]]:
query = remove_accents(query.strip().lower())
# A country-code to points mapping for later sorting countries
# based on the query's matching incidence.
results: dict[str, int] = {}
def add_result(country: "pycountry.db.Country", points: int) -> None:
results.setdefault(country.alpha_2, 0)
results[country.alpha_2] += points
# Prio 1: exact matches on country names
try:
add_result(self.lookup(query), 50)
except LookupError:
pass
# Prio 2: exact matches on subdivision names
match_subdivions = pycountry.Subdivisions.match(
self=subdivisions, query=query
)
for candidate in match_subdivions:
add_result(candidate.country, 49)
# Prio 3: partial matches on country names
for candidate in self:
# Higher priority for a match on the common name
for v in [
candidate._fields.get("name"),
candidate._fields.get("official_name"),
candidate._fields.get("comment"),
]:
if v is not None:
v = remove_accents(v.lower())
if query in v:
# This prefers countries with a match early in their name
# and also balances against countries with a number of
# partial matches and their name containing 'new' in the
# middle
add_result(
candidate, max([5, 30 - (2 * v.find(query))])
)
break
# Prio 4: partial matches on subdivision names
partial_match_subdivisions = pycountry.Subdivisions.partial_match(
self=subdivisions, query=query
)
for candidate in partial_match_subdivisions:
v = candidate._fields.get("name")
v = remove_accents(v.lower())
if query in v:
add_result(candidate.country, max([1, 5 - v.find(query)]))
if not results:
raise LookupError(query)
sorted_results = [
self.get(alpha_2=x[0])
# sort by points first, by alpha2 code second, and to ensure stable
# results the negative value allows us to sort reversely on the
# points but ascending on the country code.
for x in sorted(results.items(), key=lambda x: (-x[1], x[0]))
]
return sorted_results
class HistoricCountries(ExistingCountries):
"""Provides access to an ISO 3166-3 database
(Countries that have been removed from the standard)."""
data_class = pycountry.db.Country
root_key = "3166-3"
class Scripts(pycountry.db.Database):
"""Provides access to an ISO 15924 database (Scripts)."""
data_class = "Script"
root_key = "15924"
class Currencies(pycountry.db.Database):
"""Provides access to an ISO 4217 database (Currencies)."""
data_class = "Currency"
root_key = "4217"
class Languages(pycountry.db.Database):
"""Provides access to an ISO 639-1/2T/3 database (Languages)."""
no_index = ["status", "scope", "type", "inverted_name", "common_name"]
data_class = "Language"
root_key = "639-3"
class LanguageFamilies(pycountry.db.Database):
"""Provides access to an ISO 639-5 database
(Language Families and Groups)."""
data_class = "LanguageFamily"
root_key = "639-5"
class SubdivisionHierarchy(pycountry.db.Data):
def __init__(self, **kw):
if "parent" in kw:
kw["parent_code"] = kw["parent"]
else:
kw["parent_code"] = None
super().__init__(**kw)
self.country_code = self.code.split("-")[0]
if self.parent_code is not None:
# Split the parent_code to check if the country_code is already present
parts = self.parent_code.split("-")
if parts[0] != self.country_code:
self.parent_code = f"{self.country_code}-{self.parent_code}"
@property
def country(self):
return countries.get(alpha_2=self.country_code)
@property
def parent(self):
if not self.parent_code:
return None
return subdivisions.get(code=self.parent_code)
class Subdivisions(pycountry.db.Database):
# Note: subdivisions can be hierarchical to other subdivisions. The
# parent_code attribute is related to other subdivisions, *not*
# the country!
data_class = SubdivisionHierarchy
no_index = ["name", "parent_code", "parent", "type"]
root_key = "3166-2"
def _load(self, *args, **kw):
super()._load(*args, **kw)
# Add index for the country code.
self.indices["country_code"] = {}
for subdivision in self:
divs = self.indices["country_code"].setdefault(
subdivision.country_code.lower(), set()
)
divs.add(subdivision)
def get(self, **kw):
default = kw.setdefault("default", None)
subdivisions = super().get(**kw)
if subdivisions is default and "country_code" in kw:
# This handles the case where we know about a country but there
# are no subdivisions: we return an empty list in this case
# (sticking to the expected type here) instead of None.
if countries.get(alpha_2=kw["country_code"]) is not None:
return []
return subdivisions
def match(self, query):
query = remove_accents(query.strip().lower())
matching_candidates = []
for candidate in subdivisions:
for v in candidate._fields.values():
if v is not None:
v = remove_accents(v.lower())
# Some names include alternative versions which we want to
# match exactly.
for w in v.split(";"):
if w == query:
matching_candidates.append(candidate)
break
return matching_candidates
def partial_match(self, query):
query = remove_accents(query.strip().lower())
matching_candidates = []
for candidate in subdivisions:
v = candidate._fields.get("name")
v = remove_accents(v.lower())
if query in v:
matching_candidates.append(candidate)
return matching_candidates
def search_fuzzy(self, query: str) -> List[Type["Subdivisions"]]:
query = remove_accents(query.strip().lower())
# A Subdivision's code to points mapping for later sorting subdivisions
# based on the query's matching incidence.
results: dict[str, int] = {}
def add_result(
subdivision: "pycountry.db.Subdivision", points: int
) -> None:
results.setdefault(subdivision.code, 0)
results[subdivision.code] += points
# Prio 1: exact matches on subdivision names
match_subdivisions = self.match(query)
for candidate in match_subdivisions:
add_result(candidate, 50)
# Prio 2: partial matches on subdivision names
partial_match_subdivisions = self.partial_match(query)
for candidate in partial_match_subdivisions:
v = candidate._fields.get("name")
v = remove_accents(v.lower())
if query in v:
add_result(candidate, max([1, 5 - v.find(query)]))
if not results:
raise LookupError(query)
sorted_results = [
self.get(code=x[0])
# sort by points first, by alpha2 code second, and to ensure stable
# results the negative value allows us to sort reversely on the
# points but ascending on the country code.
for x in sorted(results.items(), key=lambda x: (-x[1], x[0]))
]
return sorted_results
# Initialize instances with type hints
countries: ExistingCountries = ExistingCountries(
os.path.join(DATABASE_DIR, "iso3166-1.json")
)
subdivisions: Subdivisions = Subdivisions(
os.path.join(DATABASE_DIR, "iso3166-2.json")
)
historic_countries: HistoricCountries = HistoricCountries(
os.path.join(DATABASE_DIR, "iso3166-3.json")
)
currencies: Currencies = Currencies(os.path.join(DATABASE_DIR, "iso4217.json"))
languages: Languages = Languages(os.path.join(DATABASE_DIR, "iso639-3.json"))
language_families: LanguageFamilies = LanguageFamilies(
os.path.join(DATABASE_DIR, "iso639-5.json")
)
scripts: Scripts = Scripts(os.path.join(DATABASE_DIR, "iso15924.json"))

View File

@@ -0,0 +1,914 @@
{
"15924": [
{
"alpha_4": "Adlm",
"name": "Adlam",
"numeric": "166"
},
{
"alpha_4": "Afak",
"name": "Afaka",
"numeric": "439"
},
{
"alpha_4": "Aghb",
"name": "Caucasian Albanian",
"numeric": "239"
},
{
"alpha_4": "Ahom",
"name": "Ahom, Tai Ahom",
"numeric": "338"
},
{
"alpha_4": "Arab",
"name": "Arabic",
"numeric": "160"
},
{
"alpha_4": "Aran",
"name": "Arabic (Nastaliq variant)",
"numeric": "161"
},
{
"alpha_4": "Armi",
"name": "Imperial Aramaic",
"numeric": "124"
},
{
"alpha_4": "Armn",
"name": "Armenian",
"numeric": "230"
},
{
"alpha_4": "Avst",
"name": "Avestan",
"numeric": "134"
},
{
"alpha_4": "Bali",
"name": "Balinese",
"numeric": "360"
},
{
"alpha_4": "Bamu",
"name": "Bamum",
"numeric": "435"
},
{
"alpha_4": "Bass",
"name": "Bassa Vah",
"numeric": "259"
},
{
"alpha_4": "Batk",
"name": "Batak",
"numeric": "365"
},
{
"alpha_4": "Beng",
"name": "Bengali",
"numeric": "325"
},
{
"alpha_4": "Bhks",
"name": "Bhaiksuki",
"numeric": "334"
},
{
"alpha_4": "Blis",
"name": "Blissymbols",
"numeric": "550"
},
{
"alpha_4": "Bopo",
"name": "Bopomofo",
"numeric": "285"
},
{
"alpha_4": "Brah",
"name": "Brahmi",
"numeric": "300"
},
{
"alpha_4": "Brai",
"name": "Braille",
"numeric": "570"
},
{
"alpha_4": "Bugi",
"name": "Buginese",
"numeric": "367"
},
{
"alpha_4": "Buhd",
"name": "Buhid",
"numeric": "372"
},
{
"alpha_4": "Cakm",
"name": "Chakma",
"numeric": "349"
},
{
"alpha_4": "Cans",
"name": "Unified Canadian Aboriginal Syllabics",
"numeric": "440"
},
{
"alpha_4": "Cari",
"name": "Carian",
"numeric": "201"
},
{
"alpha_4": "Cham",
"name": "Cham",
"numeric": "358"
},
{
"alpha_4": "Cher",
"name": "Cherokee",
"numeric": "445"
},
{
"alpha_4": "Cirt",
"name": "Cirth",
"numeric": "291"
},
{
"alpha_4": "Copt",
"name": "Coptic",
"numeric": "204"
},
{
"alpha_4": "Cprt",
"name": "Cypriot",
"numeric": "403"
},
{
"alpha_4": "Cyrl",
"name": "Cyrillic",
"numeric": "220"
},
{
"alpha_4": "Cyrs",
"name": "Cyrillic (Old Church Slavonic variant)",
"numeric": "221"
},
{
"alpha_4": "Deva",
"name": "Devanagari (Nagari)",
"numeric": "315"
},
{
"alpha_4": "Dsrt",
"name": "Deseret (Mormon)",
"numeric": "250"
},
{
"alpha_4": "Dupl",
"name": "Duployan shorthand, Duployan stenography",
"numeric": "755"
},
{
"alpha_4": "Egyd",
"name": "Egyptian demotic",
"numeric": "070"
},
{
"alpha_4": "Egyh",
"name": "Egyptian hieratic",
"numeric": "060"
},
{
"alpha_4": "Egyp",
"name": "Egyptian hieroglyphs",
"numeric": "050"
},
{
"alpha_4": "Elba",
"name": "Elbasan",
"numeric": "226"
},
{
"alpha_4": "Ethi",
"name": "Ethiopic (Geʻez)",
"numeric": "430"
},
{
"alpha_4": "Geok",
"name": "Khutsuri (Asomtavruli and Nuskhuri)",
"numeric": "241"
},
{
"alpha_4": "Geor",
"name": "Georgian (Mkhedruli)",
"numeric": "240"
},
{
"alpha_4": "Glag",
"name": "Glagolitic",
"numeric": "225"
},
{
"alpha_4": "Goth",
"name": "Gothic",
"numeric": "206"
},
{
"alpha_4": "Gran",
"name": "Grantha",
"numeric": "343"
},
{
"alpha_4": "Grek",
"name": "Greek",
"numeric": "200"
},
{
"alpha_4": "Gujr",
"name": "Gujarati",
"numeric": "320"
},
{
"alpha_4": "Guru",
"name": "Gurmukhi",
"numeric": "310"
},
{
"alpha_4": "Hanb",
"name": "Han with Bopomofo (alias for Han + Bopomofo)",
"numeric": "503"
},
{
"alpha_4": "Hang",
"name": "Hangul (Hangŭl, Hangeul)",
"numeric": "286"
},
{
"alpha_4": "Hani",
"name": "Han (Hanzi, Kanji, Hanja)",
"numeric": "500"
},
{
"alpha_4": "Hano",
"name": "Hanunoo (Hanunóo)",
"numeric": "371"
},
{
"alpha_4": "Hans",
"name": "Han (Simplified variant)",
"numeric": "501"
},
{
"alpha_4": "Hant",
"name": "Han (Traditional variant)",
"numeric": "502"
},
{
"alpha_4": "Hatr",
"name": "Hatran",
"numeric": "127"
},
{
"alpha_4": "Hebr",
"name": "Hebrew",
"numeric": "125"
},
{
"alpha_4": "Hira",
"name": "Hiragana",
"numeric": "410"
},
{
"alpha_4": "Hluw",
"name": "Anatolian Hieroglyphs (Luwian Hieroglyphs, Hittite Hieroglyphs)",
"numeric": "080"
},
{
"alpha_4": "Hmng",
"name": "Pahawh Hmong",
"numeric": "450"
},
{
"alpha_4": "Hrkt",
"name": "Japanese syllabaries (alias for Hiragana + Katakana)",
"numeric": "412"
},
{
"alpha_4": "Hung",
"name": "Old Hungarian (Hungarian Runic)",
"numeric": "176"
},
{
"alpha_4": "Inds",
"name": "Indus (Harappan)",
"numeric": "610"
},
{
"alpha_4": "Ital",
"name": "Old Italic (Etruscan, Oscan, etc.)",
"numeric": "210"
},
{
"alpha_4": "Jamo",
"name": "Jamo (alias for Jamo subset of Hangul)",
"numeric": "284"
},
{
"alpha_4": "Java",
"name": "Javanese",
"numeric": "361"
},
{
"alpha_4": "Jpan",
"name": "Japanese (alias for Han + Hiragana + Katakana)",
"numeric": "413"
},
{
"alpha_4": "Jurc",
"name": "Jurchen",
"numeric": "510"
},
{
"alpha_4": "Kali",
"name": "Kayah Li",
"numeric": "357"
},
{
"alpha_4": "Kana",
"name": "Katakana",
"numeric": "411"
},
{
"alpha_4": "Khar",
"name": "Kharoshthi",
"numeric": "305"
},
{
"alpha_4": "Khmr",
"name": "Khmer",
"numeric": "355"
},
{
"alpha_4": "Khoj",
"name": "Khojki",
"numeric": "322"
},
{
"alpha_4": "Kitl",
"name": "Khitan large script",
"numeric": "505"
},
{
"alpha_4": "Kits",
"name": "Khitan small script",
"numeric": "288"
},
{
"alpha_4": "Knda",
"name": "Kannada",
"numeric": "345"
},
{
"alpha_4": "Kore",
"name": "Korean (alias for Hangul + Han)",
"numeric": "287"
},
{
"alpha_4": "Kpel",
"name": "Kpelle",
"numeric": "436"
},
{
"alpha_4": "Kthi",
"name": "Kaithi",
"numeric": "317"
},
{
"alpha_4": "Lana",
"name": "Tai Tham (Lanna)",
"numeric": "351"
},
{
"alpha_4": "Laoo",
"name": "Lao",
"numeric": "356"
},
{
"alpha_4": "Latf",
"name": "Latin (Fraktur variant)",
"numeric": "217"
},
{
"alpha_4": "Latg",
"name": "Latin (Gaelic variant)",
"numeric": "216"
},
{
"alpha_4": "Latn",
"name": "Latin",
"numeric": "215"
},
{
"alpha_4": "Leke",
"name": "Leke",
"numeric": "364"
},
{
"alpha_4": "Lepc",
"name": "Lepcha (Róng)",
"numeric": "335"
},
{
"alpha_4": "Limb",
"name": "Limbu",
"numeric": "336"
},
{
"alpha_4": "Lina",
"name": "Linear A",
"numeric": "400"
},
{
"alpha_4": "Linb",
"name": "Linear B",
"numeric": "401"
},
{
"alpha_4": "Lisu",
"name": "Lisu (Fraser)",
"numeric": "399"
},
{
"alpha_4": "Loma",
"name": "Loma",
"numeric": "437"
},
{
"alpha_4": "Lyci",
"name": "Lycian",
"numeric": "202"
},
{
"alpha_4": "Lydi",
"name": "Lydian",
"numeric": "116"
},
{
"alpha_4": "Mahj",
"name": "Mahajani",
"numeric": "314"
},
{
"alpha_4": "Mand",
"name": "Mandaic, Mandaean",
"numeric": "140"
},
{
"alpha_4": "Mani",
"name": "Manichaean",
"numeric": "139"
},
{
"alpha_4": "Marc",
"name": "Marchen",
"numeric": "332"
},
{
"alpha_4": "Maya",
"name": "Mayan hieroglyphs",
"numeric": "090"
},
{
"alpha_4": "Mend",
"name": "Mende Kikakui",
"numeric": "438"
},
{
"alpha_4": "Merc",
"name": "Meroitic Cursive",
"numeric": "101"
},
{
"alpha_4": "Mero",
"name": "Meroitic Hieroglyphs",
"numeric": "100"
},
{
"alpha_4": "Mlym",
"name": "Malayalam",
"numeric": "347"
},
{
"alpha_4": "Modi",
"name": "Modi, Moḍī",
"numeric": "324"
},
{
"alpha_4": "Mong",
"name": "Mongolian",
"numeric": "145"
},
{
"alpha_4": "Moon",
"name": "Moon (Moon code, Moon script, Moon type)",
"numeric": "218"
},
{
"alpha_4": "Mroo",
"name": "Mro, Mru",
"numeric": "199"
},
{
"alpha_4": "Mtei",
"name": "Meitei Mayek (Meithei, Meetei)",
"numeric": "337"
},
{
"alpha_4": "Mult",
"name": "Multani",
"numeric": "323"
},
{
"alpha_4": "Mymr",
"name": "Myanmar (Burmese)",
"numeric": "350"
},
{
"alpha_4": "Narb",
"name": "Old North Arabian (Ancient North Arabian)",
"numeric": "106"
},
{
"alpha_4": "Nbat",
"name": "Nabataean",
"numeric": "159"
},
{
"alpha_4": "Newa",
"name": "Newa, Newar, Newari, Nepāla lipi",
"numeric": "333"
},
{
"alpha_4": "Nkgb",
"name": "Nakhi Geba ('Na-'Khi ²Ggŏ-¹baw, Naxi Geba)",
"numeric": "420"
},
{
"alpha_4": "Nkoo",
"name": "NKo",
"numeric": "165"
},
{
"alpha_4": "Nshu",
"name": "Nüshu",
"numeric": "499"
},
{
"alpha_4": "Ogam",
"name": "Ogham",
"numeric": "212"
},
{
"alpha_4": "Olck",
"name": "Ol Chiki (Ol Cemet, Ol, Santali)",
"numeric": "261"
},
{
"alpha_4": "Orkh",
"name": "Old Turkic, Orkhon Runic",
"numeric": "175"
},
{
"alpha_4": "Orya",
"name": "Oriya",
"numeric": "327"
},
{
"alpha_4": "Osge",
"name": "Osage",
"numeric": "219"
},
{
"alpha_4": "Osma",
"name": "Osmanya",
"numeric": "260"
},
{
"alpha_4": "Palm",
"name": "Palmyrene",
"numeric": "126"
},
{
"alpha_4": "Pauc",
"name": "Pau Cin Hau",
"numeric": "263"
},
{
"alpha_4": "Perm",
"name": "Old Permic",
"numeric": "227"
},
{
"alpha_4": "Phag",
"name": "Phags-pa",
"numeric": "331"
},
{
"alpha_4": "Phli",
"name": "Inscriptional Pahlavi",
"numeric": "131"
},
{
"alpha_4": "Phlp",
"name": "Psalter Pahlavi",
"numeric": "132"
},
{
"alpha_4": "Phlv",
"name": "Book Pahlavi",
"numeric": "133"
},
{
"alpha_4": "Phnx",
"name": "Phoenician",
"numeric": "115"
},
{
"alpha_4": "Piqd",
"name": "Klingon (KLI pIqaD)",
"numeric": "293"
},
{
"alpha_4": "Plrd",
"name": "Miao (Pollard)",
"numeric": "282"
},
{
"alpha_4": "Prti",
"name": "Inscriptional Parthian",
"numeric": "130"
},
{
"alpha_4": "Qaaa",
"name": "Reserved for private use (start)",
"numeric": "900"
},
{
"alpha_4": "Qabx",
"name": "Reserved for private use (end)",
"numeric": "949"
},
{
"alpha_4": "Rjng",
"name": "Rejang (Redjang, Kaganga)",
"numeric": "363"
},
{
"alpha_4": "Roro",
"name": "Rongorongo",
"numeric": "620"
},
{
"alpha_4": "Runr",
"name": "Runic",
"numeric": "211"
},
{
"alpha_4": "Samr",
"name": "Samaritan",
"numeric": "123"
},
{
"alpha_4": "Sara",
"name": "Sarati",
"numeric": "292"
},
{
"alpha_4": "Sarb",
"name": "Old South Arabian",
"numeric": "105"
},
{
"alpha_4": "Saur",
"name": "Saurashtra",
"numeric": "344"
},
{
"alpha_4": "Sgnw",
"name": "SignWriting",
"numeric": "095"
},
{
"alpha_4": "Shaw",
"name": "Shavian (Shaw)",
"numeric": "281"
},
{
"alpha_4": "Shrd",
"name": "Sharada, Śāradā",
"numeric": "319"
},
{
"alpha_4": "Sidd",
"name": "Siddham, Siddhaṃ, Siddhamātṛkā",
"numeric": "302"
},
{
"alpha_4": "Sind",
"name": "Khudawadi, Sindhi",
"numeric": "318"
},
{
"alpha_4": "Sinh",
"name": "Sinhala",
"numeric": "348"
},
{
"alpha_4": "Sora",
"name": "Sora Sompeng",
"numeric": "398"
},
{
"alpha_4": "Sund",
"name": "Sundanese",
"numeric": "362"
},
{
"alpha_4": "Sylo",
"name": "Syloti Nagri",
"numeric": "316"
},
{
"alpha_4": "Syrc",
"name": "Syriac",
"numeric": "135"
},
{
"alpha_4": "Syre",
"name": "Syriac (Estrangelo variant)",
"numeric": "138"
},
{
"alpha_4": "Syrj",
"name": "Syriac (Western variant)",
"numeric": "137"
},
{
"alpha_4": "Syrn",
"name": "Syriac (Eastern variant)",
"numeric": "136"
},
{
"alpha_4": "Tagb",
"name": "Tagbanwa",
"numeric": "373"
},
{
"alpha_4": "Takr",
"name": "Takri, Ṭākrī, Ṭāṅkrī",
"numeric": "321"
},
{
"alpha_4": "Tale",
"name": "Tai Le",
"numeric": "353"
},
{
"alpha_4": "Talu",
"name": "New Tai Lue",
"numeric": "354"
},
{
"alpha_4": "Taml",
"name": "Tamil",
"numeric": "346"
},
{
"alpha_4": "Tang",
"name": "Tangut",
"numeric": "520"
},
{
"alpha_4": "Tavt",
"name": "Tai Viet",
"numeric": "359"
},
{
"alpha_4": "Telu",
"name": "Telugu",
"numeric": "340"
},
{
"alpha_4": "Teng",
"name": "Tengwar",
"numeric": "290"
},
{
"alpha_4": "Tfng",
"name": "Tifinagh (Berber)",
"numeric": "120"
},
{
"alpha_4": "Tglg",
"name": "Tagalog (Baybayin, Alibata)",
"numeric": "370"
},
{
"alpha_4": "Thaa",
"name": "Thaana",
"numeric": "170"
},
{
"alpha_4": "Thai",
"name": "Thai",
"numeric": "352"
},
{
"alpha_4": "Tibt",
"name": "Tibetan",
"numeric": "330"
},
{
"alpha_4": "Tirh",
"name": "Tirhuta",
"numeric": "326"
},
{
"alpha_4": "Ugar",
"name": "Ugaritic",
"numeric": "040"
},
{
"alpha_4": "Vaii",
"name": "Vai",
"numeric": "470"
},
{
"alpha_4": "Visp",
"name": "Visible Speech",
"numeric": "280"
},
{
"alpha_4": "Wara",
"name": "Warang Citi (Varang Kshiti)",
"numeric": "262"
},
{
"alpha_4": "Wole",
"name": "Woleai",
"numeric": "480"
},
{
"alpha_4": "Xpeo",
"name": "Old Persian",
"numeric": "030"
},
{
"alpha_4": "Xsux",
"name": "Cuneiform, Sumero-Akkadian",
"numeric": "020"
},
{
"alpha_4": "Yiii",
"name": "Yi",
"numeric": "460"
},
{
"alpha_4": "Zinh",
"name": "Code for inherited script",
"numeric": "994"
},
{
"alpha_4": "Zmth",
"name": "Mathematical notation",
"numeric": "995"
},
{
"alpha_4": "Zsye",
"name": "Symbols (Emoji variant)",
"numeric": "993"
},
{
"alpha_4": "Zsym",
"name": "Symbols",
"numeric": "996"
},
{
"alpha_4": "Zxxx",
"name": "Code for unwritten documents",
"numeric": "997"
},
{
"alpha_4": "Zyyy",
"name": "Code for undetermined script",
"numeric": "998"
},
{
"alpha_4": "Zzzz",
"name": "Code for uncoded script",
"numeric": "999"
}
]
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,254 @@
{
"3166-3": [
{
"alpha_2": "AI",
"alpha_3": "AFI",
"alpha_4": "AIDJ",
"name": "French Afars and Issas",
"numeric": "262",
"withdrawal_date": "1977"
},
{
"alpha_2": "AN",
"alpha_3": "ANT",
"alpha_4": "ANHH",
"comment": "had numeric code 532 until Aruba split away in 1986",
"name": "Netherlands Antilles",
"numeric": "530",
"withdrawal_date": "2010-12-15"
},
{
"alpha_2": "BQ",
"alpha_3": "ATB",
"alpha_4": "BQAQ",
"name": "British Antarctic Territory",
"withdrawal_date": "1979"
},
{
"alpha_2": "BU",
"alpha_3": "BUR",
"alpha_4": "BUMM",
"name": "Burma, Socialist Republic of the Union of",
"numeric": "104",
"withdrawal_date": "1989-12-05"
},
{
"alpha_2": "BY",
"alpha_3": "BYS",
"alpha_4": "BYAA",
"name": "Byelorussian SSR Soviet Socialist Republic",
"numeric": "112",
"withdrawal_date": "1992-06-15"
},
{
"alpha_2": "CS",
"alpha_3": "CSK",
"alpha_4": "CSHH",
"name": "Czechoslovakia, Czechoslovak Socialist Republic",
"numeric": "200",
"withdrawal_date": "1993-06-15"
},
{
"alpha_2": "CS",
"alpha_3": "SCG",
"alpha_4": "CSXX",
"name": "Serbia and Montenegro",
"numeric": "891",
"withdrawal_date": "2006-09-26"
},
{
"alpha_2": "CT",
"alpha_3": "CTE",
"alpha_4": "CTKI",
"name": "Canton and Enderbury Islands",
"numeric": "128",
"withdrawal_date": "1984"
},
{
"alpha_2": "DD",
"alpha_3": "DDR",
"alpha_4": "DDDE",
"name": "German Democratic Republic",
"numeric": "278",
"withdrawal_date": "1990-10-30"
},
{
"alpha_2": "DY",
"alpha_3": "DHY",
"alpha_4": "DYBJ",
"name": "Dahomey",
"numeric": "204",
"withdrawal_date": "1977"
},
{
"alpha_2": "FQ",
"alpha_3": "ATF",
"alpha_4": "FQHH",
"comment": "now split between AQ and TF",
"name": "French Southern and Antarctic Territories",
"withdrawal_date": "1979"
},
{
"alpha_2": "FX",
"alpha_3": "FXX",
"alpha_4": "FXFR",
"name": "France, Metropolitan",
"numeric": "249",
"withdrawal_date": "1997-07-14"
},
{
"alpha_2": "GE",
"alpha_3": "GEL",
"alpha_4": "GEHH",
"comment": "now split into Kiribati and Tuvalu",
"name": "Gilbert and Ellice Islands",
"numeric": "296",
"withdrawal_date": "1979"
},
{
"alpha_2": "HV",
"alpha_3": "HVO",
"alpha_4": "HVBF",
"name": "Upper Volta, Republic of",
"numeric": "854",
"withdrawal_date": "1984"
},
{
"alpha_2": "JT",
"alpha_3": "JTN",
"alpha_4": "JTUM",
"name": "Johnston Island",
"numeric": "396",
"withdrawal_date": "1986"
},
{
"alpha_2": "MI",
"alpha_3": "MID",
"alpha_4": "MIUM",
"name": "Midway Islands",
"numeric": "488",
"withdrawal_date": "1986"
},
{
"alpha_2": "NH",
"alpha_3": "NHB",
"alpha_4": "NHVU",
"name": "New Hebrides",
"numeric": "548",
"withdrawal_date": "1980"
},
{
"alpha_2": "NQ",
"alpha_3": "ATN",
"alpha_4": "NQAQ",
"name": "Dronning Maud Land",
"numeric": "216",
"withdrawal_date": "1983"
},
{
"alpha_2": "NT",
"alpha_3": "NTZ",
"alpha_4": "NTHH",
"comment": "formerly between Saudi Arabia and Iraq",
"name": "Neutral Zone",
"numeric": "536",
"withdrawal_date": "1993-07-12"
},
{
"alpha_2": "PC",
"alpha_3": "PCI",
"alpha_4": "PCHH",
"comment": "divided into FM, MH, MP, and PW",
"name": "Pacific Islands (trust territory)",
"numeric": "582",
"withdrawal_date": "1986"
},
{
"alpha_2": "PU",
"alpha_3": "PUS",
"alpha_4": "PUUM",
"name": "US Miscellaneous Pacific Islands",
"numeric": "849",
"withdrawal_date": "1986"
},
{
"alpha_2": "PZ",
"alpha_3": "PCZ",
"alpha_4": "PZPA",
"name": "Panama Canal Zone",
"withdrawal_date": "1980"
},
{
"alpha_2": "RH",
"alpha_3": "RHO",
"alpha_4": "RHZW",
"name": "Southern Rhodesia",
"numeric": "716",
"withdrawal_date": "1980"
},
{
"alpha_2": "SK",
"alpha_3": "SKM",
"alpha_4": "SKIN",
"name": "Sikkim",
"withdrawal_date": "1975"
},
{
"alpha_2": "SU",
"alpha_3": "SUN",
"alpha_4": "SUHH",
"name": "USSR, Union of Soviet Socialist Republics",
"numeric": "810",
"withdrawal_date": "1992-08-30"
},
{
"alpha_2": "TP",
"alpha_3": "TMP",
"alpha_4": "TPTL",
"comment": "was Portuguese Timor",
"name": "East Timor",
"numeric": "626",
"withdrawal_date": "2002-05-20"
},
{
"alpha_2": "VD",
"alpha_3": "VDR",
"alpha_4": "VDVN",
"name": "Viet-Nam, Democratic Republic of",
"withdrawal_date": "1977"
},
{
"alpha_2": "WK",
"alpha_3": "WAK",
"alpha_4": "WKUM",
"name": "Wake Island",
"numeric": "872",
"withdrawal_date": "1986"
},
{
"alpha_2": "YD",
"alpha_3": "YMD",
"alpha_4": "YDYE",
"name": "Yemen, Democratic, People's Democratic Republic of",
"numeric": "720",
"withdrawal_date": "1990-08-14"
},
{
"alpha_2": "YU",
"alpha_3": "YUG",
"alpha_4": "YUCS",
"comment": "had numeric code 890 until the 'Socialist Federal Republic of Yugoslavia' formerly broke apart on 27 April 1992 and the 'Federal Republic of Yugoslavia' was founded",
"name": "Yugoslavia, (Socialist) Federal Republic of",
"numeric": "891",
"withdrawal_date": "2003-07-23"
},
{
"alpha_2": "ZR",
"alpha_3": "ZAR",
"alpha_4": "ZRCD",
"name": "Zaire, Republic of",
"numeric": "180",
"withdrawal_date": "1997-07-14"
}
]
}

View File

@@ -0,0 +1,909 @@
{
"4217": [
{
"alpha_3": "AED",
"name": "UAE Dirham",
"numeric": "784"
},
{
"alpha_3": "AFN",
"name": "Afghani",
"numeric": "971"
},
{
"alpha_3": "ALL",
"name": "Lek",
"numeric": "008"
},
{
"alpha_3": "AMD",
"name": "Armenian Dram",
"numeric": "051"
},
{
"alpha_3": "ANG",
"name": "Netherlands Antillean Guilder",
"numeric": "532"
},
{
"alpha_3": "AOA",
"name": "Kwanza",
"numeric": "973"
},
{
"alpha_3": "ARS",
"name": "Argentine Peso",
"numeric": "032"
},
{
"alpha_3": "AUD",
"name": "Australian Dollar",
"numeric": "036"
},
{
"alpha_3": "AWG",
"name": "Aruban Florin",
"numeric": "533"
},
{
"alpha_3": "AZN",
"name": "Azerbaijan Manat",
"numeric": "944"
},
{
"alpha_3": "BAM",
"name": "Convertible Mark",
"numeric": "977"
},
{
"alpha_3": "BBD",
"name": "Barbados Dollar",
"numeric": "052"
},
{
"alpha_3": "BDT",
"name": "Taka",
"numeric": "050"
},
{
"alpha_3": "BGN",
"name": "Bulgarian Lev",
"numeric": "975"
},
{
"alpha_3": "BHD",
"name": "Bahraini Dinar",
"numeric": "048"
},
{
"alpha_3": "BIF",
"name": "Burundi Franc",
"numeric": "108"
},
{
"alpha_3": "BMD",
"name": "Bermudian Dollar",
"numeric": "060"
},
{
"alpha_3": "BND",
"name": "Brunei Dollar",
"numeric": "096"
},
{
"alpha_3": "BOB",
"name": "Boliviano",
"numeric": "068"
},
{
"alpha_3": "BOV",
"name": "Mvdol",
"numeric": "984"
},
{
"alpha_3": "BRL",
"name": "Brazilian Real",
"numeric": "986"
},
{
"alpha_3": "BSD",
"name": "Bahamian Dollar",
"numeric": "044"
},
{
"alpha_3": "BTN",
"name": "Ngultrum",
"numeric": "064"
},
{
"alpha_3": "BWP",
"name": "Pula",
"numeric": "072"
},
{
"alpha_3": "BYN",
"name": "Belarusian Ruble",
"numeric": "933"
},
{
"alpha_3": "BZD",
"name": "Belize Dollar",
"numeric": "084"
},
{
"alpha_3": "CAD",
"name": "Canadian Dollar",
"numeric": "124"
},
{
"alpha_3": "CDF",
"name": "Congolese Franc",
"numeric": "976"
},
{
"alpha_3": "CHE",
"name": "WIR Euro",
"numeric": "947"
},
{
"alpha_3": "CHF",
"name": "Swiss Franc",
"numeric": "756"
},
{
"alpha_3": "CHW",
"name": "WIR Franc",
"numeric": "948"
},
{
"alpha_3": "CLF",
"name": "Unidad de Fomento",
"numeric": "990"
},
{
"alpha_3": "CLP",
"name": "Chilean Peso",
"numeric": "152"
},
{
"alpha_3": "CNY",
"name": "Yuan Renminbi",
"numeric": "156"
},
{
"alpha_3": "COP",
"name": "Colombian Peso",
"numeric": "170"
},
{
"alpha_3": "COU",
"name": "Unidad de Valor Real",
"numeric": "970"
},
{
"alpha_3": "CRC",
"name": "Costa Rican Colon",
"numeric": "188"
},
{
"alpha_3": "CUC",
"name": "Peso Convertible",
"numeric": "931"
},
{
"alpha_3": "CUP",
"name": "Cuban Peso",
"numeric": "192"
},
{
"alpha_3": "CVE",
"name": "Cabo Verde Escudo",
"numeric": "132"
},
{
"alpha_3": "CZK",
"name": "Czech Koruna",
"numeric": "203"
},
{
"alpha_3": "DJF",
"name": "Djibouti Franc",
"numeric": "262"
},
{
"alpha_3": "DKK",
"name": "Danish Krone",
"numeric": "208"
},
{
"alpha_3": "DOP",
"name": "Dominican Peso",
"numeric": "214"
},
{
"alpha_3": "DZD",
"name": "Algerian Dinar",
"numeric": "012"
},
{
"alpha_3": "EGP",
"name": "Egyptian Pound",
"numeric": "818"
},
{
"alpha_3": "ERN",
"name": "Nakfa",
"numeric": "232"
},
{
"alpha_3": "ETB",
"name": "Ethiopian Birr",
"numeric": "230"
},
{
"alpha_3": "EUR",
"name": "Euro",
"numeric": "978"
},
{
"alpha_3": "FJD",
"name": "Fiji Dollar",
"numeric": "242"
},
{
"alpha_3": "FKP",
"name": "Falkland Islands Pound",
"numeric": "238"
},
{
"alpha_3": "GBP",
"name": "Pound Sterling",
"numeric": "826"
},
{
"alpha_3": "GEL",
"name": "Lari",
"numeric": "981"
},
{
"alpha_3": "GHS",
"name": "Ghana Cedi",
"numeric": "936"
},
{
"alpha_3": "GIP",
"name": "Gibraltar Pound",
"numeric": "292"
},
{
"alpha_3": "GMD",
"name": "Dalasi",
"numeric": "270"
},
{
"alpha_3": "GNF",
"name": "Guinean Franc",
"numeric": "324"
},
{
"alpha_3": "GTQ",
"name": "Quetzal",
"numeric": "320"
},
{
"alpha_3": "GYD",
"name": "Guyana Dollar",
"numeric": "328"
},
{
"alpha_3": "HKD",
"name": "Hong Kong Dollar",
"numeric": "344"
},
{
"alpha_3": "HNL",
"name": "Lempira",
"numeric": "340"
},
{
"alpha_3": "HRK",
"name": "Kuna",
"numeric": "191"
},
{
"alpha_3": "HTG",
"name": "Gourde",
"numeric": "332"
},
{
"alpha_3": "HUF",
"name": "Forint",
"numeric": "348"
},
{
"alpha_3": "IDR",
"name": "Rupiah",
"numeric": "360"
},
{
"alpha_3": "ILS",
"name": "New Israeli Sheqel",
"numeric": "376"
},
{
"alpha_3": "INR",
"name": "Indian Rupee",
"numeric": "356"
},
{
"alpha_3": "IQD",
"name": "Iraqi Dinar",
"numeric": "368"
},
{
"alpha_3": "IRR",
"name": "Iranian Rial",
"numeric": "364"
},
{
"alpha_3": "ISK",
"name": "Iceland Krona",
"numeric": "352"
},
{
"alpha_3": "JMD",
"name": "Jamaican Dollar",
"numeric": "388"
},
{
"alpha_3": "JOD",
"name": "Jordanian Dinar",
"numeric": "400"
},
{
"alpha_3": "JPY",
"name": "Yen",
"numeric": "392"
},
{
"alpha_3": "KES",
"name": "Kenyan Shilling",
"numeric": "404"
},
{
"alpha_3": "KGS",
"name": "Som",
"numeric": "417"
},
{
"alpha_3": "KHR",
"name": "Riel",
"numeric": "116"
},
{
"alpha_3": "KMF",
"name": "Comorian Franc",
"numeric": "174"
},
{
"alpha_3": "KPW",
"name": "North Korean Won",
"numeric": "408"
},
{
"alpha_3": "KRW",
"name": "Won",
"numeric": "410"
},
{
"alpha_3": "KWD",
"name": "Kuwaiti Dinar",
"numeric": "414"
},
{
"alpha_3": "KYD",
"name": "Cayman Islands Dollar",
"numeric": "136"
},
{
"alpha_3": "KZT",
"name": "Tenge",
"numeric": "398"
},
{
"alpha_3": "LAK",
"name": "Lao Kip",
"numeric": "418"
},
{
"alpha_3": "LBP",
"name": "Lebanese Pound",
"numeric": "422"
},
{
"alpha_3": "LKR",
"name": "Sri Lanka Rupee",
"numeric": "144"
},
{
"alpha_3": "LRD",
"name": "Liberian Dollar",
"numeric": "430"
},
{
"alpha_3": "LSL",
"name": "Loti",
"numeric": "426"
},
{
"alpha_3": "LYD",
"name": "Libyan Dinar",
"numeric": "434"
},
{
"alpha_3": "MAD",
"name": "Moroccan Dirham",
"numeric": "504"
},
{
"alpha_3": "MDL",
"name": "Moldovan Leu",
"numeric": "498"
},
{
"alpha_3": "MGA",
"name": "Malagasy Ariary",
"numeric": "969"
},
{
"alpha_3": "MKD",
"name": "Denar",
"numeric": "807"
},
{
"alpha_3": "MMK",
"name": "Kyat",
"numeric": "104"
},
{
"alpha_3": "MNT",
"name": "Tugrik",
"numeric": "496"
},
{
"alpha_3": "MOP",
"name": "Pataca",
"numeric": "446"
},
{
"alpha_3": "MRU",
"name": "Ouguiya",
"numeric": "929"
},
{
"alpha_3": "MUR",
"name": "Mauritius Rupee",
"numeric": "480"
},
{
"alpha_3": "MVR",
"name": "Rufiyaa",
"numeric": "462"
},
{
"alpha_3": "MWK",
"name": "Malawi Kwacha",
"numeric": "454"
},
{
"alpha_3": "MXN",
"name": "Mexican Peso",
"numeric": "484"
},
{
"alpha_3": "MXV",
"name": "Mexican Unidad de Inversion (UDI)",
"numeric": "979"
},
{
"alpha_3": "MYR",
"name": "Malaysian Ringgit",
"numeric": "458"
},
{
"alpha_3": "MZN",
"name": "Mozambique Metical",
"numeric": "943"
},
{
"alpha_3": "NAD",
"name": "Namibia Dollar",
"numeric": "516"
},
{
"alpha_3": "NGN",
"name": "Naira",
"numeric": "566"
},
{
"alpha_3": "NIO",
"name": "Cordoba Oro",
"numeric": "558"
},
{
"alpha_3": "NOK",
"name": "Norwegian Krone",
"numeric": "578"
},
{
"alpha_3": "NPR",
"name": "Nepalese Rupee",
"numeric": "524"
},
{
"alpha_3": "NZD",
"name": "New Zealand Dollar",
"numeric": "554"
},
{
"alpha_3": "OMR",
"name": "Rial Omani",
"numeric": "512"
},
{
"alpha_3": "PAB",
"name": "Balboa",
"numeric": "590"
},
{
"alpha_3": "PEN",
"name": "Sol",
"numeric": "604"
},
{
"alpha_3": "PGK",
"name": "Kina",
"numeric": "598"
},
{
"alpha_3": "PHP",
"name": "Philippine Peso",
"numeric": "608"
},
{
"alpha_3": "PKR",
"name": "Pakistan Rupee",
"numeric": "586"
},
{
"alpha_3": "PLN",
"name": "Zloty",
"numeric": "985"
},
{
"alpha_3": "PYG",
"name": "Guarani",
"numeric": "600"
},
{
"alpha_3": "QAR",
"name": "Qatari Rial",
"numeric": "634"
},
{
"alpha_3": "RON",
"name": "Romanian Leu",
"numeric": "946"
},
{
"alpha_3": "RSD",
"name": "Serbian Dinar",
"numeric": "941"
},
{
"alpha_3": "RUB",
"name": "Russian Ruble",
"numeric": "643"
},
{
"alpha_3": "RWF",
"name": "Rwanda Franc",
"numeric": "646"
},
{
"alpha_3": "SAR",
"name": "Saudi Riyal",
"numeric": "682"
},
{
"alpha_3": "SBD",
"name": "Solomon Islands Dollar",
"numeric": "090"
},
{
"alpha_3": "SCR",
"name": "Seychelles Rupee",
"numeric": "690"
},
{
"alpha_3": "SDG",
"name": "Sudanese Pound",
"numeric": "938"
},
{
"alpha_3": "SEK",
"name": "Swedish Krona",
"numeric": "752"
},
{
"alpha_3": "SGD",
"name": "Singapore Dollar",
"numeric": "702"
},
{
"alpha_3": "SHP",
"name": "Saint Helena Pound",
"numeric": "654"
},
{
"alpha_3": "SLE",
"name": "Leone",
"numeric": "925"
},
{
"alpha_3": "SLL",
"name": "Leone",
"numeric": "694"
},
{
"alpha_3": "SOS",
"name": "Somali Shilling",
"numeric": "706"
},
{
"alpha_3": "SRD",
"name": "Surinam Dollar",
"numeric": "968"
},
{
"alpha_3": "SSP",
"name": "South Sudanese Pound",
"numeric": "728"
},
{
"alpha_3": "STN",
"name": "Dobra",
"numeric": "930"
},
{
"alpha_3": "SVC",
"name": "El Salvador Colon",
"numeric": "222"
},
{
"alpha_3": "SYP",
"name": "Syrian Pound",
"numeric": "760"
},
{
"alpha_3": "SZL",
"name": "Lilangeni",
"numeric": "748"
},
{
"alpha_3": "THB",
"name": "Baht",
"numeric": "764"
},
{
"alpha_3": "TJS",
"name": "Somoni",
"numeric": "972"
},
{
"alpha_3": "TMT",
"name": "Turkmenistan New Manat",
"numeric": "934"
},
{
"alpha_3": "TND",
"name": "Tunisian Dinar",
"numeric": "788"
},
{
"alpha_3": "TOP",
"name": "Paanga",
"numeric": "776"
},
{
"alpha_3": "TRY",
"name": "Turkish Lira",
"numeric": "949"
},
{
"alpha_3": "TTD",
"name": "Trinidad and Tobago Dollar",
"numeric": "780"
},
{
"alpha_3": "TWD",
"name": "New Taiwan Dollar",
"numeric": "901"
},
{
"alpha_3": "TZS",
"name": "Tanzanian Shilling",
"numeric": "834"
},
{
"alpha_3": "UAH",
"name": "Hryvnia",
"numeric": "980"
},
{
"alpha_3": "UGX",
"name": "Uganda Shilling",
"numeric": "800"
},
{
"alpha_3": "USD",
"name": "US Dollar",
"numeric": "840"
},
{
"alpha_3": "USN",
"name": "US Dollar (Next day)",
"numeric": "997"
},
{
"alpha_3": "UYI",
"name": "Uruguay Peso en Unidades Indexadas (UI)",
"numeric": "940"
},
{
"alpha_3": "UYU",
"name": "Peso Uruguayo",
"numeric": "858"
},
{
"alpha_3": "UYW",
"name": "Unidad Previsional",
"numeric": "927"
},
{
"alpha_3": "UZS",
"name": "Uzbekistan Sum",
"numeric": "860"
},
{
"alpha_3": "VED",
"name": "Bolívar Soberano",
"numeric": "926"
},
{
"alpha_3": "VES",
"name": "Bolívar Soberano",
"numeric": "928"
},
{
"alpha_3": "VND",
"name": "Dong",
"numeric": "704"
},
{
"alpha_3": "VUV",
"name": "Vatu",
"numeric": "548"
},
{
"alpha_3": "WST",
"name": "Tala",
"numeric": "882"
},
{
"alpha_3": "XAF",
"name": "CFA Franc BEAC",
"numeric": "950"
},
{
"alpha_3": "XAG",
"name": "Silver",
"numeric": "961"
},
{
"alpha_3": "XAU",
"name": "Gold",
"numeric": "959"
},
{
"alpha_3": "XBA",
"name": "Bond Markets Unit European Composite Unit (EURCO)",
"numeric": "955"
},
{
"alpha_3": "XBB",
"name": "Bond Markets Unit European Monetary Unit (E.M.U.-6)",
"numeric": "956"
},
{
"alpha_3": "XBC",
"name": "Bond Markets Unit European Unit of Account 9 (E.U.A.-9)",
"numeric": "957"
},
{
"alpha_3": "XBD",
"name": "Bond Markets Unit European Unit of Account 17 (E.U.A.-17)",
"numeric": "958"
},
{
"alpha_3": "XCD",
"name": "East Caribbean Dollar",
"numeric": "951"
},
{
"alpha_3": "XDR",
"name": "SDR (Special Drawing Right)",
"numeric": "960"
},
{
"alpha_3": "XOF",
"name": "CFA Franc BCEAO",
"numeric": "952"
},
{
"alpha_3": "XPD",
"name": "Palladium",
"numeric": "964"
},
{
"alpha_3": "XPF",
"name": "CFP Franc",
"numeric": "953"
},
{
"alpha_3": "XPT",
"name": "Platinum",
"numeric": "962"
},
{
"alpha_3": "XSU",
"name": "Sucre",
"numeric": "994"
},
{
"alpha_3": "XTS",
"name": "Codes specifically reserved for testing purposes",
"numeric": "963"
},
{
"alpha_3": "XUA",
"name": "ADB Unit of Account",
"numeric": "965"
},
{
"alpha_3": "XXX",
"name": "The codes assigned for transactions where no currency is involved",
"numeric": "999"
},
{
"alpha_3": "YER",
"name": "Yemeni Rial",
"numeric": "886"
},
{
"alpha_3": "ZAR",
"name": "Rand",
"numeric": "710"
},
{
"alpha_3": "ZMW",
"name": "Zambian Kwacha",
"numeric": "967"
},
{
"alpha_3": "ZWL",
"name": "Zimbabwe Dollar",
"numeric": "932"
}
]
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,464 @@
{
"639-5": [
{
"alpha_3": "aav",
"name": "Austro-Asiatic languages"
},
{
"alpha_3": "afa",
"name": "Afro-Asiatic languages"
},
{
"alpha_3": "alg",
"name": "Algonquian languages"
},
{
"alpha_3": "alv",
"name": "Atlantic-Congo languages"
},
{
"alpha_3": "apa",
"name": "Apache languages"
},
{
"alpha_3": "aqa",
"name": "Alacalufan languages"
},
{
"alpha_3": "aql",
"name": "Algic languages"
},
{
"alpha_3": "art",
"name": "Artificial languages"
},
{
"alpha_3": "ath",
"name": "Athapascan languages"
},
{
"alpha_3": "auf",
"name": "Arauan languages"
},
{
"alpha_3": "aus",
"name": "Australian languages"
},
{
"alpha_3": "awd",
"name": "Arawakan languages"
},
{
"alpha_3": "azc",
"name": "Uto-Aztecan languages"
},
{
"alpha_3": "bad",
"name": "Banda languages"
},
{
"alpha_3": "bai",
"name": "Bamileke languages"
},
{
"alpha_3": "bat",
"name": "Baltic languages"
},
{
"alpha_3": "ber",
"name": "Berber languages"
},
{
"alpha_3": "bih",
"name": "Bihari languages"
},
{
"alpha_3": "bnt",
"name": "Bantu languages"
},
{
"alpha_3": "btk",
"name": "Batak languages"
},
{
"alpha_3": "cai",
"name": "Central American Indian languages"
},
{
"alpha_3": "cau",
"name": "Caucasian languages"
},
{
"alpha_3": "cba",
"name": "Chibchan languages"
},
{
"alpha_3": "ccn",
"name": "North Caucasian languages"
},
{
"alpha_3": "ccs",
"name": "South Caucasian languages"
},
{
"alpha_3": "cdc",
"name": "Chadic languages"
},
{
"alpha_3": "cdd",
"name": "Caddoan languages"
},
{
"alpha_3": "cel",
"name": "Celtic languages"
},
{
"alpha_3": "cmc",
"name": "Chamic languages"
},
{
"alpha_3": "cpe",
"name": "Creoles and pidgins, Englishbased"
},
{
"alpha_3": "cpf",
"name": "Creoles and pidgins, Frenchbased"
},
{
"alpha_3": "cpp",
"name": "Creoles and pidgins, Portuguese-based"
},
{
"alpha_3": "crp",
"name": "Creoles and pidgins"
},
{
"alpha_3": "csu",
"name": "Central Sudanic languages"
},
{
"alpha_3": "cus",
"name": "Cushitic languages"
},
{
"alpha_3": "day",
"name": "Land Dayak languages"
},
{
"alpha_3": "dmn",
"name": "Mande languages"
},
{
"alpha_3": "dra",
"name": "Dravidian languages"
},
{
"alpha_3": "egx",
"name": "Egyptian languages"
},
{
"alpha_3": "esx",
"name": "Eskimo-Aleut languages"
},
{
"alpha_3": "euq",
"name": "Basque (family)"
},
{
"alpha_3": "fiu",
"name": "Finno-Ugrian languages"
},
{
"alpha_3": "fox",
"name": "Formosan languages"
},
{
"alpha_3": "gem",
"name": "Germanic languages"
},
{
"alpha_3": "gme",
"name": "East Germanic languages"
},
{
"alpha_3": "gmq",
"name": "North Germanic languages"
},
{
"alpha_3": "gmw",
"name": "West Germanic languages"
},
{
"alpha_3": "grk",
"name": "Greek languages"
},
{
"alpha_3": "hmx",
"name": "Hmong-Mien languages"
},
{
"alpha_3": "hok",
"name": "Hokan languages"
},
{
"alpha_3": "hyx",
"name": "Armenian (family)"
},
{
"alpha_3": "iir",
"name": "Indo-Iranian languages"
},
{
"alpha_3": "ijo",
"name": "Ijo languages"
},
{
"alpha_3": "inc",
"name": "Indic languages"
},
{
"alpha_3": "ine",
"name": "Indo-European languages"
},
{
"alpha_3": "ira",
"name": "Iranian languages"
},
{
"alpha_3": "iro",
"name": "Iroquoian languages"
},
{
"alpha_3": "itc",
"name": "Italic languages"
},
{
"alpha_3": "jpx",
"name": "Japanese (family)"
},
{
"alpha_3": "kar",
"name": "Karen languages"
},
{
"alpha_3": "kdo",
"name": "Kordofanian languages"
},
{
"alpha_3": "khi",
"name": "Khoisan languages"
},
{
"alpha_3": "kro",
"name": "Kru languages"
},
{
"alpha_3": "map",
"name": "Austronesian languages"
},
{
"alpha_3": "mkh",
"name": "Mon-Khmer languages"
},
{
"alpha_3": "mno",
"name": "Manobo languages"
},
{
"alpha_3": "mun",
"name": "Munda languages"
},
{
"alpha_3": "myn",
"name": "Mayan languages"
},
{
"alpha_3": "nah",
"name": "Nahuatl languages"
},
{
"alpha_3": "nai",
"name": "North American Indian languages"
},
{
"alpha_3": "ngf",
"name": "Trans-New Guinea languages"
},
{
"alpha_3": "nic",
"name": "Niger-Kordofanian languages"
},
{
"alpha_3": "nub",
"name": "Nubian languages"
},
{
"alpha_3": "omq",
"name": "Oto-Manguean languages"
},
{
"alpha_3": "omv",
"name": "Omotic languages"
},
{
"alpha_3": "oto",
"name": "Otomian languages"
},
{
"alpha_3": "paa",
"name": "Papuan languages"
},
{
"alpha_3": "phi",
"name": "Philippine languages"
},
{
"alpha_3": "plf",
"name": "Central Malayo-Polynesian languages"
},
{
"alpha_3": "poz",
"name": "Malayo-Polynesian languages"
},
{
"alpha_3": "pqe",
"name": "Eastern Malayo-Polynesian languages"
},
{
"alpha_3": "pqw",
"name": "Western Malayo-Polynesian languages"
},
{
"alpha_3": "pra",
"name": "Prakrit languages"
},
{
"alpha_3": "qwe",
"name": "Quechuan (family)"
},
{
"alpha_3": "roa",
"name": "Romance languages"
},
{
"alpha_3": "sai",
"name": "South American Indian languages"
},
{
"alpha_3": "sal",
"name": "Salishan languages"
},
{
"alpha_3": "sdv",
"name": "Eastern Sudanic languages"
},
{
"alpha_3": "sem",
"name": "Semitic languages"
},
{
"alpha_3": "sgn",
"name": "sign languages"
},
{
"alpha_3": "sio",
"name": "Siouan languages"
},
{
"alpha_3": "sit",
"name": "Sino-Tibetan languages"
},
{
"alpha_3": "sla",
"name": "Slavic languages"
},
{
"alpha_3": "smi",
"name": "Sami languages"
},
{
"alpha_3": "son",
"name": "Songhai languages"
},
{
"alpha_3": "sqj",
"name": "Albanian languages"
},
{
"alpha_3": "ssa",
"name": "Nilo-Saharan languages"
},
{
"alpha_3": "syd",
"name": "Samoyedic languages"
},
{
"alpha_3": "tai",
"name": "Tai languages"
},
{
"alpha_3": "tbq",
"name": "Tibeto-Burman languages"
},
{
"alpha_3": "trk",
"name": "Turkic languages"
},
{
"alpha_3": "tup",
"name": "Tupi languages"
},
{
"alpha_3": "tut",
"name": "Altaic languages"
},
{
"alpha_3": "tuw",
"name": "Tungus languages"
},
{
"alpha_3": "urj",
"name": "Uralic languages"
},
{
"alpha_3": "wak",
"name": "Wakashan languages"
},
{
"alpha_3": "wen",
"name": "Sorbian languages"
},
{
"alpha_3": "xgn",
"name": "Mongolian languages"
},
{
"alpha_3": "xnd",
"name": "Na-Dene languages"
},
{
"alpha_3": "ypk",
"name": "Yupik languages"
},
{
"alpha_3": "zhx",
"name": "Chinese (family)"
},
{
"alpha_3": "zle",
"name": "East Slavic languages"
},
{
"alpha_3": "zls",
"name": "South Slavic languages"
},
{
"alpha_3": "zlw",
"name": "West Slavic languages"
},
{
"alpha_3": "znd",
"name": "Zande languages"
}
]
}

View File

@@ -0,0 +1,200 @@
import json
import logging
import threading
from typing import Any, Iterator, List, Optional, Type, Union
logger = logging.getLogger("pycountry.db")
class Data:
def __init__(self, **fields: str):
self._fields = fields
def __getattr__(self, key):
if key in self._fields:
return self._fields[key]
raise AttributeError(key)
def __setattr__(self, key: str, value: str) -> None:
if key != "_fields":
self._fields[key] = value
super().__setattr__(key, value)
def __repr__(self) -> str:
cls_name = self.__class__.__name__
fields = ", ".join("%s=%r" % i for i in sorted(self._fields.items()))
return f"{cls_name}({fields})"
def __dir__(self) -> List[str]:
return dir(self.__class__) + list(self._fields)
def __iter__(self):
# allow casting into a dict
for field in self._fields:
yield field, getattr(self, field)
class Country(Data):
pass
class Subdivision(Data):
pass
def lazy_load(f):
def load_if_needed(self, *args, **kw):
if not self._is_loaded:
with self._load_lock:
self._load()
return f(self, *args, **kw)
return load_if_needed
class Database:
data_class: Union[Type, str]
root_key: Optional[str] = None
no_index: List[str] = []
def __init__(self, filename: str) -> None:
self.filename = filename
self._is_loaded = False
self._load_lock = threading.Lock()
if isinstance(self.data_class, str):
self.factory = type(self.data_class, (Data,), {})
else:
self.factory = self.data_class
def _clear(self):
self._is_loaded = False
self.objects = []
self.index_names = set()
self.indices = {}
def _load(self) -> None:
if self._is_loaded:
# Help keeping the _load_if_needed code easier
# to read.
return
self._clear()
with open(self.filename, encoding="utf-8") as f:
tree = json.load(f)
for entry in tree[self.root_key]:
obj = self.factory(**entry)
self.objects.append(obj)
# Inject into index.
for key, value in entry.items():
if key in self.no_index:
continue
# Lookups and searches are case insensitive. Normalize
# here.
index = self.indices.setdefault(key, {})
value = value.lower()
if value in index:
logger.debug(
"%s %r already taken in index %r and will be "
"ignored. This is an error in the databases."
% (self.factory.__name__, value, key)
)
index[value] = obj
self._is_loaded = True
# Public API
@lazy_load
def add_entry(self, **kw):
# create the object with the correct dynamic type
obj = self.factory(**kw)
# append object
self.objects.append(obj)
# update indices
for key, value in kw.items():
if key in self.no_index:
continue
value = value.lower()
index = self.indices.setdefault(key, {})
index[value] = obj
@lazy_load
def remove_entry(self, **kw):
# make sure that we receive None if no entry found
if "default" in kw:
del kw["default"]
obj = self.get(**kw)
if not obj:
raise KeyError(
f"{self.factory.__name__} not found and cannot be removed: {kw}"
)
# remove object
self.objects.remove(obj)
# update indices
for key, value in obj:
if key in self.no_index:
continue
value = value.lower()
index = self.indices.setdefault(key, {})
if value in index:
del index[value]
@lazy_load
def __iter__(self) -> Iterator["Database"]:
return iter(self.objects)
@lazy_load
def __len__(self) -> int:
return len(self.objects)
@lazy_load
def get(
self, *, default: Optional[Any] = None, **kw: Optional[str]
) -> Optional[Any]:
if len(kw) != 1:
raise TypeError("Only one criteria may be given")
field, value = kw.popitem()
if not isinstance(value, str):
raise LookupError()
# Normalize for case-insensitivity
value = value.lower()
index = self.indices[field]
try:
return index[value]
except KeyError:
# Pythonic APIs implementing get() shouldn't raise KeyErrors.
# Those are a bit unexpected and they should rather support
# returning `None` by default and allow customization.
return default
@lazy_load
def lookup(self, value: str) -> Type:
if not isinstance(value, str):
raise LookupError()
# Normalize for case-insensitivity
value = value.lower()
# Use indexes first
for key in self.indices:
try:
return self.indices[key][value]
except LookupError:
pass
# Use non-indexed values now. Avoid going through indexed values.
for candidate in self:
for k in self.no_index:
v = candidate._fields.get(k)
if v is None:
continue
if v.lower() == value:
return candidate
raise LookupError("Could not find a record for %r" % value)

Some files were not shown because too many files have changed in this diff Show More