Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_country(code):
try:
return get_countries()[code]
except KeyError:
country = pycountry.historic_countries.get(alpha_2=code)
return country.name if country else None
def getCountryById(cls, cid):
"""
Returns the country, given its ID
"""
country_name = cls._countries.get(cid, None)
if country_name:
return country_name
else:
try:
return pycountry.historic_countries.get(alpha2=cid).name.encode('utf-8')
except KeyError:
return None