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
=== modified file 'ibid/plugins/lookup.py'
--- ibid/plugins/lookup.py 2009-05-12 07:13:41 +0000
+++ ibid/plugins/lookup.py 2009-05-30 16:43:53 +0000
@@ -7,6 +7,7 @@
7from simplejson import loads7from simplejson import loads
8from xml.dom.minidom import parse8from xml.dom.minidom import parse
9import re9import re
10import logging
1011
11import feedparser12import feedparser
1213
@@ -14,6 +15,8 @@
14from ibid.config import Option15from ibid.config import Option
15from ibid.utils import ago, decode_htmlentities, get_html_parse_tree, cacheable_download16from ibid.utils import ago, decode_htmlentities, get_html_parse_tree, cacheable_download
1617
18log = logging.getLogger('plugins.lookup')
19
17help = {}20help = {}
1821
19def get_country_codes():22def get_country_codes():
@@ -270,7 +273,6 @@
270 headers = {'User-Agent': 'Mozilla/5.0', 'Referer': 'http://www.xe.com/'}273 headers = {'User-Agent': 'Mozilla/5.0', 'Referer': 'http://www.xe.com/'}
271 currencies = {}274 currencies = {}
272 country_codes = {}275 country_codes = {}
273 strip_currency_re = re.compile(r'^[\.\s]*([\w\s]+?)s?$', re.UNICODE)
274276
275 def _load_currencies(self):277 def _load_currencies(self):
276 etree = get_html_parse_tree('http://www.xe.com/iso4217.php', headers=self.headers, treetype='etree')278 etree = get_html_parse_tree('http://www.xe.com/iso4217.php', headers=self.headers, treetype='etree')
@@ -299,11 +301,13 @@
299 currency[0].append(place)301 currency[0].append(place)
300 else:302 else:
301 self.currencies[code] = [[place], name.strip()]303 self.currencies[code] = [[place], name.strip()]
304
302 # Special cases for shared currencies:305 # Special cases for shared currencies:
303 self.currencies['EUR'][0].insert(0, u'Euro Member Countries')306 self.currencies['EUR'][0].insert(0, u'Euro Member Countries')
304 self.currencies['XOF'][0].insert(0, u'Communaut\xe9 Financi\xe8re Africaine')307 self.currencies['XOF'][0].insert(0, u'Communaut\xe9 Financi\xe8re Africaine')
305 self.currencies['XOF'][1] = u'Francs'308 self.currencies['XOF'][1] = u'Francs'
306309
310 strip_currency_re = re.compile(r'^[\.\s]*([\w\s]+?)s?$', re.UNICODE)
307311
308 def _resolve_currency(self, name, rough=True):312 def _resolve_currency(self, name, rough=True):
309 "Return the canonical name for a currency"313 "Return the canonical name for a currency"
@@ -311,7 +315,12 @@
311 if name.upper() in self.currencies:315 if name.upper() in self.currencies:
312 return name.upper()316 return name.upper()
313317
314 name = self.strip_currency_re.match(name).group(1).lower()318 m = self.strip_currency_re.match(name)
319
320 if m is None:
321 return False
322
323 name = m.group(1).lower()
315324
316 # TLD -> country name325 # TLD -> country name
317 if rough and len(name) == 2 and name.upper() in self.country_codes:326 if rough and len(name) == 2 and name.upper() in self.country_codes:

Subscribers

People subscribed via source and target branches