How to use the iso3166.countries_by_alpha3 function in iso3166

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 icon-project / icon-service / iconservice / prep / data / prep.py View on Github external
def _get_country(cls, alpha3_country_code: str) -> "iso3166.Country":
        return iso3166.countries_by_alpha3.get(
            alpha3_country_code.upper(), cls._UNKNOWN_COUNTRY
        )
github icon-project / icon-service / iconservice / prep / validator.py View on Github external
def _validate_country(country_code: str):
    if country_code.upper() not in iso3166.countries_by_alpha3:
        raise InvalidParamsException("Invalid alpha-3 country code")
github eflglobal / filters / filters / iso.py View on Github external
countries_by_alpha2,
            countries_by_alpha3,
            Country as CountryType,
        )

        value = self._filter(value, Type(string_types + (CountryType,)))

        if self._has_errors:
            return None

        if isinstance(value, CountryType):
            return value

        search_functions = {
            2: countries_by_alpha2,
            3: countries_by_alpha3,
        }

        try:
            return search_functions[len(value)][value.upper()]
        except KeyError:
            return self._invalid_value(value, self.CODE_INVALID, exc_info=True)

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