How to use the countrynames.to_code function in countrynames

To help you get started, we’ve selected a few countrynames 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 alephdata / opensanctions / opensanctions / models.py View on Github external
def country(self, name):
        self.country_name = name
        self.country_code = countrynames.to_code(name)
github alephdata / opensanctions / opensanctions / util.py View on Github external
def normalize_country(name):
    return countrynames.to_code(name)
github alephdata / opensanctions / peplib / source.py View on Github external
def normalize_country(self, name):
        return countrynames.to_code(name)
github alephdata / aleph / aleph / data / parse.py View on Github external
def parse_country(country, guess=True):
    """Determine a two-letter country code based on an input.

    The input may be a country code, a country name, etc.
    """
    if guess:
        country = countrynames.to_code(country)
    if country is not None:
        country = country.lower()
        if is_country_code(country):
            return country
github alephdata / followthemoney / followthemoney / types / country.py View on Github external
def clean_text(self, country, fuzzy=False, **kwargs):
        """Determine a two-letter country code based on an input.

        The input may be a country code, a country name, etc.
        """
        code = country.lower().strip()
        if code in self.codes:
            return code
        country = countrynames.to_code(country, fuzzy=fuzzy)
        if country is not None:
            return country.lower()

countrynames

A library to map country names to ISO codes.

MIT
Latest version published 25 days ago

Package Health Score

72 / 100
Full package analysis

Similar packages