Merge lp:~stefanor/ibid/currency-test-failures into lp:ibid

Proposed by Stefano Rivera
Status: Merged
Approved by: Stefano Rivera
Approved revision: 1048
Merged at revision: 1047
Proposed branch: lp:~stefanor/ibid/currency-test-failures
Merge into: lp:ibid
Diff against target: 61 lines (+7/-14)
2 files modified
ibid/plugins/conversions.py (+2/-10)
ibid/utils/__init__.py (+5/-4)
To merge this branch: bzr merge lp:~stefanor/ibid/currency-test-failures
Reviewer Review Type Date Requested Status
Jonathan Hitchcock Approve
Review via email: mp+117198@code.launchpad.net

Commit message

Fix test failures now that the ISO-3166 list is UTF-8, and has a one-line header.

Description of the change

We currently can't land branches because some tsets are failing.

This fixes that.

To post a comment you must log in.
Revision history for this message
Jonathan Hitchcock (vhata) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ibid/plugins/conversions.py'
2--- ibid/plugins/conversions.py 2011-10-23 21:10:52 +0000
3+++ ibid/plugins/conversions.py 2012-07-29 19:50:23 +0000
4@@ -357,24 +357,16 @@
5 and code[:2] not in self.country_currencies):
6 self.country_currencies[code[:2]] = code
7 continue
8- ascii_place = (unicodedata.normalize('NFD', unicode(place))
9- .encode('ASCII', 'ignore')
10- .replace('-', ' ')
11- .replace('Sint', 'Saint'))
12
13 # Countries with (alternative names)
14 swapped_place = None
15- m = re.match(r'^(.+?)\s+\((.+)\)$', ascii_place)
16+ m = re.match(r'^(.+?)\s+\((.+)\)$', place)
17 if m is not None:
18 swapped_place = '%s (%s)' % (m.group(2), m.group(1))
19
20 for ccode, country in self.country_codes.iteritems():
21 country = country.title()
22- ascii_country = (unicodedata.normalize('NFD', country)
23- .encode('ASCII', 'ignore')
24- .replace('-', ' ')
25- .replace('Sint', 'Saint'))
26- if ascii_country in (ascii_place, swapped_place):
27+ if country in (place, swapped_place):
28 if ccode not in self.country_currencies:
29 self.country_currencies[ccode] = code
30 break
31
32=== modified file 'ibid/utils/__init__.py'
33--- ibid/utils/__init__.py 2011-08-20 15:06:44 +0000
34+++ ibid/utils/__init__.py 2012-07-29 19:50:23 +0000
35@@ -361,7 +361,7 @@
36 'http://www.iso.org/iso/list-en1-semic-3.txt',
37 'lookup/iso-3166-1_list_en.txt')
38
39- f = codecs.open(filename, 'r', 'ISO-8859-1')
40+ f = codecs.open(filename, 'r', 'UTF-8')
41 countries = {
42 u'AC': u'Ascension Island',
43 u'UK': u'United Kingdom',
44@@ -374,14 +374,15 @@
45 started = False
46 for line in f:
47 line = line.strip()
48- if started and ';' in line:
49+ if not started:
50+ started = True
51+ continue
52+ if ';' in line:
53 country, code = line.split(u';')
54 country = country.lower()
55 # Hack around http://bugs.python.org/issue7008
56 country = country.title().replace(u"'S", u"'s")
57 countries[code] = country
58- elif line == u'':
59- started = True
60
61 f.close()
62

Subscribers

People subscribed via source and target branches

to all changes: