mirror of
https://github.com/jlu5/SupyPlugins.git
synced 2025-05-07 12:03:43 -05:00
Wikifetch: only show "possible results" in disambiguation pages if parsing succeeds
This commit is contained in:
parent
d1eea2a0a4
commit
9f1f04d25c
@ -177,20 +177,22 @@ class Wikifetch(callbacks.Plugin):
|
|||||||
tree.xpath('//table[@id="setindexbox"]') or \
|
tree.xpath('//table[@id="setindexbox"]') or \
|
||||||
tree.xpath('//div[contains(@class, "disambig")]') # Wikia (2017-01-27)
|
tree.xpath('//div[contains(@class, "disambig")]') # Wikia (2017-01-27)
|
||||||
if disambig:
|
if disambig:
|
||||||
|
reply += format(_('%u is a disambiguation page. '), addr)
|
||||||
disambig = tree.xpath('//div[@id="bodyContent"]/div/ul/li')
|
disambig = tree.xpath('//div[@id="bodyContent"]/div/ul/li')
|
||||||
# Hackishly bold all <a> tags
|
|
||||||
r = []
|
disambig_results = []
|
||||||
for item in disambig:
|
for item in disambig:
|
||||||
for link in item.findall('a'):
|
for link in item.findall('a'):
|
||||||
if link.text is not None:
|
if link.text is not None:
|
||||||
|
# Hackishly bold all <a> tags
|
||||||
link.text = "%s" % link.text
|
link.text = "%s" % link.text
|
||||||
item = item.text_content().replace('', '\x02')
|
item = item.text_content().replace('', '\x02')
|
||||||
# Normalize and strip whitespace, to prevent newlines and such
|
# Normalize and strip whitespace, to prevent newlines and such
|
||||||
# from corrupting the display.
|
# from corrupting the display.
|
||||||
item = utils.str.normalizeWhitespace(item).strip()
|
item = utils.str.normalizeWhitespace(item).strip()
|
||||||
r.append(item)
|
disambig_results.append(item)
|
||||||
reply += format(_('%u is a disambiguation page. '
|
if disambig_results:
|
||||||
'Possible results include: %L'), addr, r)
|
reply += format(_('Possible results include: %L'), disambig_results)
|
||||||
|
|
||||||
# Catch talk pages
|
# Catch talk pages
|
||||||
elif 'ns-talk' in tree.find("body").attrib['class']:
|
elif 'ns-talk' in tree.find("body").attrib['class']:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user