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(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))