Port to python3, fix ssl support
This commit is contained in:
@@ -23,7 +23,7 @@ def text(html):
|
||||
return text
|
||||
|
||||
def wiktionary(word):
|
||||
bytes = web.get(uri % web.urllib.quote(word.encode('utf-8')))
|
||||
bytes = web.get(uri % web.urllib.quote(word))
|
||||
bytes = r_ul.sub('', bytes)
|
||||
|
||||
mode = None
|
||||
@@ -62,11 +62,11 @@ parts = ('preposition', 'particle', 'noun', 'verb',
|
||||
'adjective', 'adverb', 'interjection')
|
||||
|
||||
def format(word, definitions, number=2):
|
||||
result = '%s' % word.encode('utf-8')
|
||||
result = '%s' % word
|
||||
for part in parts:
|
||||
if definitions.has_key(part):
|
||||
if part in definitions:
|
||||
defs = definitions[part][:number]
|
||||
result += u' \u2014 '.encode('utf-8') + ('%s: ' % part)
|
||||
result += ' \u2014 ' + ('%s: ' % part)
|
||||
n = ['%s. %s' % (i + 1, e.strip(' .')) for i, e in enumerate(defs)]
|
||||
result += ', '.join(n)
|
||||
return result.strip(' .,')
|
||||
@@ -97,4 +97,4 @@ def encarta(phenny, input):
|
||||
encarta.commands = ['dict']
|
||||
|
||||
if __name__ == '__main__':
|
||||
print __doc__.strip()
|
||||
print(__doc__.strip())
|
||||
|
||||
Reference in New Issue
Block a user