Beispiel #1
0
 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))
Beispiel #2
0
 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))