Merge lp:~stefanor/ibid/html5lib-524660 into lp:~ibid-core/ibid/old-trunk-1.6

Proposed by Stefano Rivera
Status: Merged
Approved by: Jonathan Hitchcock
Approved revision: not available
Merged at revision: 895
Proposed branch: lp:~stefanor/ibid/html5lib-524660
Merge into: lp:~ibid-core/ibid/old-trunk-1.6
Diff against target: 29 lines (+8/-4)
1 file modified
ibid/utils/html.py (+8/-4)
To merge this branch: bzr merge lp:~stefanor/ibid/html5lib-524660
Reviewer Review Type Date Requested Status
Jonathan Hitchcock Approve
marcog (community) Approve
Michael Gorven Approve
Review via email: mp+19748@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
marcog (marco-gallotta) wrote :

Query: exchange 1 usd to zar
ERROR:scripts.ibid-plugin:Exception occured in Currency processor of conversions plugin
Traceback (most recent call last):
  File "/home/marco/ibid/html5lib-524660/scripts/ibid-plugin", line 129, in <module>
    processor.process(event)
  File "./ibid/plugins/__init__.py", line 119, in process
    method(event, *match.groups())
  File "./ibid/plugins/conversions.py", line 368, in exchange
    self._load_currencies()
  File "./ibid/plugins/conversions.py", line 303, in _load_currencies
    etree = get_html_parse_tree('http://www.xe.com/iso4217.php', headers=self.headers, treetype='etree')
  File "./ibid/utils/html.py", line 55, in get_html_parse_tree
    namespaceHTMLElements=False)
TypeError: __init__() got an unexpected keyword argument 'namespaceHTMLElements'

review: Needs Fixing
lp:~stefanor/ibid/html5lib-524660 updated
891. By Stefano Rivera

Support old html5libs too

Revision history for this message
Stefano Rivera (stefanor) wrote :

> TypeError: __init__() got an unexpected keyword argument
> 'namespaceHTMLElements'

Fixed in r891.

Revision history for this message
marcog (marco-gallotta) :
review: Approve
Revision history for this message
Jonathan Hitchcock (vhata) wrote :

Nice.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ibid/utils/html.py'
2--- ibid/utils/html.py 2010-01-21 14:19:42 +0000
3+++ ibid/utils/html.py 2010-02-21 10:14:15 +0000
4@@ -2,6 +2,7 @@
5 # Released under terms of the MIT/X/Expat Licence. See COPYING for details.
6
7 import cgi
8+import inspect
9 import zlib
10 import urllib2
11 from gzip import GzipFile
12@@ -50,11 +51,14 @@
13 if treetype == "beautifulsoup":
14 return BeautifulSoup(data, convertEntities=BeautifulSoup.HTML_ENTITIES)
15 elif treetype == "etree":
16- treebuilder = treebuilders.getTreeBuilder("etree", ElementTree)
17+ kwargs = {'tree': treebuilders.getTreeBuilder('etree', ElementTree)}
18+ # http://code.google.com/p/html5lib/issues/detail?id=138
19+ if ('namespaceHTMLElements'
20+ in inspect.getargspec(HTMLParser.__init__)[0]):
21+ kwargs['namespaceHTMLElements'] = False
22+ parser = HTMLParser(**kwargs)
23 else:
24- treebuilder = treebuilders.getTreeBuilder(treetype)
25-
26- parser = HTMLParser(tree=treebuilder)
27+ parser = HTMLParser(tree=treebuilders.getTreeBuilder(treetype))
28
29 return parser.parse(data, encoding = encoding)
30

Subscribers

People subscribed via source and target branches