How to use iso3166 - 10 common examples

To help you get started, we’ve selected a few iso3166 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github graydon / country-bounding-boxes / country_bounding_boxes / __init__.py View on Github external
def _best_guess_iso_2(c):
    iso3 = _best_guess_iso_3(c)
    if iso3 is None:
        return None
    isoc = iso3166.countries.get(iso3)
    if isoc is None:
        return None
    iso2 = isoc.alpha2
    if c.iso_a2 != "-99" and _is_iso_2_name(c.iso_a2):
        assert c.iso_a2 == iso2
    return iso2
github Pseudomanifold / Auceps / make_choropleth_map.py View on Github external
        lambda x: iso3166.countries.get(x).alpha3, df['code'].values))
github davidmcclure / open-syllabus-project / osp / institutions / models / institution_index.py View on Github external
def materialize_country_facets(cls, counts):

        """
        Materialize country facet counts.

        Returns:
            dict: {label, value, count}
        """

        facets = []
        for abbr, count in counts:

            country = countries.get(abbr)

            if country:
                facets.append(dict(
                    label = country.name,
                    value = abbr.upper(),
                    count = count,
                ))

        return facets
github davidmcclure / open-syllabus-project / osp / citations / validator.py View on Github external
Returns: bool
        """

        a = ' '.join(text.surname_tokens)
        t = ' '.join(text.title_tokens)

        return (

            # US states
            us.states.lookup(a) or
            us.states.lookup(t) or

            # Countries
            iso3166.countries.get(a, None) or
            iso3166.countries.get(t, None)
github streamlink / streamlink / src / streamlink / utils / l10n.py View on Github external
def get(cls, country):
        try:
            if PYCOUNTRY:
                c = countries.lookup(country)
                return Country(c.alpha_2, c.alpha_3, c.numeric, c.name, getattr(c, "official_name", c.name))
            else:
                c = countries.get(country)
                return Country(c.alpha2, c.alpha3, c.numeric, c.name, c.apolitical_name)
        except (LookupError, KeyError):
            raise LookupError("Invalid country code: {0}".format(country))
github davidmcclure / open-syllabus-project / osp / citations / utils.py View on Github external
def is_toponym(value):

    """
    Is a string the name of a US state or country?

    Args:
        value (str)

    Returns: bool
    """

    return bool(
        iso3166.countries.get(value, None) or
        us.states.lookup(value)
    )
github mapbox / mapbox-sdk-py / mapbox / services / geocoding.py View on Github external
def country_codes(self):
        """A list of valid country codes"""
        return [c.alpha2.lower() for c in countries]
github xeBuz / Flask-Validator / flask_validator / constraints / location.py View on Github external
def check_value(self, value):
        try:
            countries.get(value)
            return True
        except KeyError:
            return False
github graydon / country-bounding-boxes / country_bounding_boxes / __init__.py View on Github external
def _is_iso_3_name(n):
    if len(_iso_3_names) == 0:
        for c in iso3166.countries:
            _iso_3_names.add(c.alpha3)
    return n in _iso_3_names

iso3166

Self-contained ISO 3166-1 country definitions.

MIT
Latest version published 2 years ago

Package Health Score

55 / 100
Full package analysis

Similar packages