Merge lp:~stefanor/ibid/exchange-377577 into lp:~ibid-core/ibid/old-trunk-pack-0.92

Proposed by Stefano Rivera
Status: Merged
Approved by: Jonathan Hitchcock
Approved revision: 645
Merged at revision: 658
Proposed branch: lp:~stefanor/ibid/exchange-377577
Merge into: lp:~ibid-core/ibid/old-trunk-pack-0.92
Diff against target: None lines
To merge this branch: bzr merge lp:~stefanor/ibid/exchange-377577
Reviewer Review Type Date Requested Status
Jonathan Hitchcock Approve
Michael Gorven Approve
Review via email: mp+6905@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Michael Gorven (mgorven) wrote :

 review approve

review: Approve
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/lookup.py'
2--- ibid/plugins/lookup.py 2009-05-12 07:13:41 +0000
3+++ ibid/plugins/lookup.py 2009-05-30 16:43:53 +0000
4@@ -7,6 +7,7 @@
5 from simplejson import loads
6 from xml.dom.minidom import parse
7 import re
8+import logging
9
10 import feedparser
11
12@@ -14,6 +15,8 @@
13 from ibid.config import Option
14 from ibid.utils import ago, decode_htmlentities, get_html_parse_tree, cacheable_download
15
16+log = logging.getLogger('plugins.lookup')
17+
18 help = {}
19
20 def get_country_codes():
21@@ -270,7 +273,6 @@
22 headers = {'User-Agent': 'Mozilla/5.0', 'Referer': 'http://www.xe.com/'}
23 currencies = {}
24 country_codes = {}
25- strip_currency_re = re.compile(r'^[\.\s]*([\w\s]+?)s?$', re.UNICODE)
26
27 def _load_currencies(self):
28 etree = get_html_parse_tree('http://www.xe.com/iso4217.php', headers=self.headers, treetype='etree')
29@@ -299,11 +301,13 @@
30 currency[0].append(place)
31 else:
32 self.currencies[code] = [[place], name.strip()]
33+
34 # Special cases for shared currencies:
35 self.currencies['EUR'][0].insert(0, u'Euro Member Countries')
36 self.currencies['XOF'][0].insert(0, u'Communaut\xe9 Financi\xe8re Africaine')
37 self.currencies['XOF'][1] = u'Francs'
38
39+ strip_currency_re = re.compile(r'^[\.\s]*([\w\s]+?)s?$', re.UNICODE)
40
41 def _resolve_currency(self, name, rough=True):
42 "Return the canonical name for a currency"
43@@ -311,7 +315,12 @@
44 if name.upper() in self.currencies:
45 return name.upper()
46
47- name = self.strip_currency_re.match(name).group(1).lower()
48+ m = self.strip_currency_re.match(name)
49+
50+ if m is None:
51+ return False
52+
53+ name = m.group(1).lower()
54
55 # TLD -> country name
56 if rough and len(name) == 2 and name.upper() in self.country_codes:

Subscribers

People subscribed via source and target branches