From 79ddce0bcb3eb20531684f7065190f4d6c1cc571 Mon Sep 17 00:00:00 2001 From: "Brian S. Stephan" Date: Mon, 23 Jan 2012 22:05:25 -0600 Subject: [PATCH] Babelfish: already a smattering of bugfixes and cleanups --- modules/Babelfish.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/modules/Babelfish.py b/modules/Babelfish.py index d75273c..d09a701 100644 --- a/modules/Babelfish.py +++ b/modules/Babelfish.py @@ -35,9 +35,7 @@ class Babelfish(Module): """Handle IRC input.""" match = re.search('^!translate\s+(\S+)\s+(\S+)\s+(.*)$', what) - print(what) if match: - print('match') fromlang = match.group(1) tolang = match.group(2) text = match.group(3) @@ -60,9 +58,9 @@ class Babelfish(Module): req.add_header('Accept-Charset', 'UTF-8,*;q=0.5') res = urllib2.urlopen(req) content = res.read() - start_idx = content.find('
', start_idx) translation = content[start_idx:end_idx] # do some text conversion @@ -71,13 +69,14 @@ class Babelfish(Module): translation = translation.replace('<', '<') translation = translation.replace('>', '>') translation = translation.replace(''', '\'') - translation = text.replace('< ', '<') # crappy attempt at undoing the safety above + translation = translation.replace(''', '\'') + translation = translation.replace('< ', '<') # crappy attempt at undoing the safety above return translation if __name__ == '__main__': babelfish = Babelfish(None, None, None) - print('\'' + babelfish.translate('en', 'ja', '') + '\'') + print('\'' + babelfish.translate('en', 'ja', 'i can\'t read it, there aren\'t any words there') + '\'') # vi:tabstop=4:expandtab:autoindent # kate: indent-mode python;indent-width 4;replace-tabs on;