From 8f2e14481a186ed725262d47c0ba39537288826f Mon Sep 17 00:00:00 2001 From: "Sean B. Palmer" Date: Sun, 2 Mar 2008 14:28:02 +0000 Subject: [PATCH] Some Wikipedia encoding fixes. --- modules/wikipedia.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/modules/wikipedia.py b/modules/wikipedia.py index 5489872..18a55f6 100755 --- a/modules/wikipedia.py +++ b/modules/wikipedia.py @@ -57,7 +57,9 @@ def search(term): def wikipedia(term, last=False): global wikiuri - bytes = web.get(wikiuri % urllib.quote(term)) + if not '%' in term: + bytes = web.get(wikiuri % urllib.quote(term)) + else: bytes = web.get(wikiuri % term) bytes = r_tr.sub('', bytes) if not last: @@ -123,8 +125,9 @@ def wikipedia(term, last=False): sentence = '"' + sentence.replace('"', "'") + '"' sentence = sentence.decode('utf-8').encode('utf-8') - wikiuri = wikiuri.encode('utf-8') - return sentence + ' - ' + (wikiuri % term.encode('utf-8')) + wikiuri = wikiuri.decode('utf-8').encode('utf-8') + term = term.decode('utf-8').encode('utf-8') + return sentence + ' - ' + (wikiuri % term) def wik(phenny, input): origterm = input.groups()[1]