Merge lp:~mvo/software-center/rfc3166-use-common-name into lp:software-center

Proposed by Michael Vogt
Status: Merged
Merged at revision: 2761
Proposed branch: lp:~mvo/software-center/rfc3166-use-common-name
Merge into: lp:software-center
Diff against target: 39 lines (+9/-2)
2 files modified
softwarecenter/region.py (+4/-1)
test/test_region.py (+5/-1)
To merge this branch: bzr merge lp:~mvo/software-center/rfc3166-use-common-name
Reviewer Review Type Date Requested Status
Gary Lasker (community) Approve
Review via email: mp+93158@code.launchpad.net

Description of the change

This small branch ensures that "common_name" in rfc3166 is used when available to avoid political issues around the name of the region.

To post a comment you must log in.
Revision history for this message
Gary Lasker (gary-lasker) wrote :

Nice!! This is a great thing to have. Thanks mvo!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'softwarecenter/region.py'
2--- softwarecenter/region.py 2012-02-03 09:42:18 +0000
3+++ softwarecenter/region.py 2012-02-15 08:55:46 +0000
4@@ -48,7 +48,10 @@
5 xpath = ".//%s_entry[@alpha_2_code='%s']" % (iso, countrycode)
6 match = root.find(xpath)
7 if match is not None:
8- return dgettext(iso, match.attrib["name"])
9+ name = match.attrib.get("common_name")
10+ if not name:
11+ name = match.attrib["name"]
12+ return dgettext(iso, name)
13 return ""
14
15 # the first parameter of SetRequirements
16
17=== modified file 'test/test_region.py'
18--- test/test_region.py 2012-02-02 20:33:37 +0000
19+++ test/test_region.py 2012-02-15 08:55:46 +0000
20@@ -7,7 +7,7 @@
21
22 from testutils import setup_test_env
23 setup_test_env()
24-from softwarecenter.region import RegionDiscover
25+from softwarecenter.region import RegionDiscover, get_region_name
26 from softwarecenter.i18n import init_locale
27
28 class TestRegion(unittest.TestCase):
29@@ -24,6 +24,10 @@
30 self.assertEqual(res["country"], "Zambia")
31 os.environ["LANG"] = ""
32
33+ def test_get_region_name(self):
34+ self.assertEqual(get_region_name("BO"), "Bolivia")
35+ self.assertEqual(get_region_name("DE"), "Germany")
36+
37 def test_get_region_geoclue(self):
38 res = self.region._get_region_geoclue()
39 self.assertNotEqual(len(res), 0)

Subscribers

People subscribed via source and target branches