def get_region_name(countrycode):
""" return translated region name from countrycode using iso3166 """
# find translated name
if countrycode:
for iso in ["iso_3166", "iso_3166_2"]:
path = os.path.join("/usr/share/xml/iso-codes/", iso + ".xml")
if os.path.exists(path):
root = xml.etree.ElementTree.parse(path)
xpath = ".//%s_entry[@alpha_2_code='%s']" % (iso, countrycode)
match = root.find(xpath)
if match is not None:
name = match.attrib.get("common_name")
if not name:
name = match.attrib["name"]
return dgettext(iso, name)
return ""
# the first parameter of SetRequirements
评论列表
文章目录