~ubuntu-branches/ubuntu/raring/software-center/raring-proposed

« back to all changes in this revision

Viewing changes to softwarecenter/region.py

  • Committer: Package Import Robot
  • Author(s): Michael Vogt
  • Date: 2012-10-11 15:33:05 UTC
  • mfrom: (195.1.18 quantal)
  • Revision ID: package-import@ubuntu.com-20121011153305-fm5ln7if3rpzts4n
Tags: 5.4.1.1
* lp:~mvo/software-center/reinstall-previous-purchase-token-fix:
  - fix reinstall previous purchases that have a system-wide
    license key LP: #1065481
* lp:~mvo/software-center/lp1060106:
  - Add missing gettext init for utils/update-software-center-agent
    (LP: #1060106)

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
import locale
25
25
import logging
26
26
import os
27
 
import xml.etree.ElementTree
 
27
 
28
28
from gettext import dgettext
29
29
from gettext import gettext as _
30
30
 
38
38
 
39
39
# blacklist this region
40
40
REGION_BLACKLIST_TAG = "blacklist-iso3166::"
 
41
# or whitelist it
 
42
REGION_WHITELIST_TAG = "whitelist-iso3166::"
41
43
 
42
44
 
43
45
def get_region_name(countrycode):
44
46
    """ return translated region name from countrycode using iso3166 """
 
47
    from lxml import etree
45
48
    # find translated name
46
49
    if countrycode:
47
50
        for iso in ["iso_3166", "iso_3166_2"]:
48
51
            path = os.path.join("/usr/share/xml/iso-codes/", iso + ".xml")
49
52
            if os.path.exists(path):
50
 
                root = xml.etree.ElementTree.parse(path)
 
53
                root = etree.parse(path)
51
54
                xpath = ".//%s_entry[@alpha_2_code='%s']" % (iso, countrycode)
52
55
                match = root.find(xpath)
53
56
                if match is not None: