region.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:x-mario-center 作者: fossasia 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号