diff --git a/.travis.yml b/.travis.yml index 9711ef6..8887dbe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,7 @@ language: python python: - "2.7" + - "3.4" - pypy # command to install dependencies, install: diff --git a/__init__.py b/__init__.py index 161b14c..c71edeb 100644 --- a/__init__.py +++ b/__init__.py @@ -25,11 +25,11 @@ __author__ = supybot.authors.unknown __contributors__ = {} # This is a url where the most recent plugin package can be downloaded. -__url__ = '' # 'http://supybot.com/Members/yourname/UrbanDictionary/download' +__url__ = '' -import config -import plugin -reload(config) +from . import config +from . import plugin +from imp import reload reload(plugin) # In case we're being reloaded. # Add more reloads here if you add third-party modules and want them to be # reloaded when this plugin is reloaded. Don't forget to import them as well! @@ -40,5 +40,4 @@ if world.testing: Class = plugin.Class configure = config.configure - # vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: diff --git a/config.py b/config.py index 0245e7f..d625e8d 100644 --- a/config.py +++ b/config.py @@ -22,6 +22,6 @@ def configure(advanced): UrbanDictionary = conf.registerPlugin('UrbanDictionary') conf.registerGlobalValue(UrbanDictionary, 'maxNumberOfDefinitions', registry.Integer(10, """Number of definition and examples in output. Max 10.""")) -conf.registerGlobalValue(UrbanDictionary, 'disableANSI', registry.Boolean(False, """Do not display any ANSI (color/bold) in output.""")) +conf.registerGlobalValue(UrbanDictionary, 'disableANSI', registry.Boolean(False, """Do not display any ANSI formatting codes in output.""")) # vim:set shiftwidth=4 tabstop=4 expandtab textwidth=250: diff --git a/plugin.py b/plugin.py index 299c2bf..082327d 100644 --- a/plugin.py +++ b/plugin.py @@ -5,6 +5,7 @@ # # ### +from __future__ import unicode_literals # my libs import json import re @@ -111,7 +112,7 @@ class UrbanDictionary(callbacks.Plugin): try: jsondata = self._repairjson(html.decode('utf-8')) # decode utf-8. fix \r\n that ud puts in below. jsondata = json.loads(jsondata) # odds chars in UD. - except Exception, e: + except Exception as e: self.log.error("Error parsing JSON from UD: {0}".format(e)) irc.reply("ERROR: Failed to parse json data. Check logs for error") return @@ -122,15 +123,15 @@ class UrbanDictionary(callbacks.Plugin): if results == "exact": # we did not find anything. outdefs = [] for i in definitions[0:args['numberOfDefinitions']]: # iterate through each def. - outputstring = "{0}".format(i['definition'].encode('utf-8').strip()) # default string. + outputstring = "{0}".format(i['definition'].strip()) # default string. if args['showExamples']: # show examples? - outputstring += " {0} {1} {2}".format(self._bu("[ex:]"), i['example'].encode('utf-8').strip(), self._bu("[/ex]")) + outputstring += " {0} {1} {2}".format(self._bu("[ex:]"), i['example'].strip(), self._bu("[/ex]")) if args['showVotes']: # show votes? outputstring += " (+{0}/-{1})".format(i['thumbs_up'], i['thumbs_down']) outdefs.append(outputstring) # add to our list. output = " | ".join([item for item in outdefs]) # create string with everything. elif results == "fulltext": # not direct. yields related terms. - output = " | ".join(sorted(set([item['word'].encode('utf-8') for item in definitions]))) # sorted, unique words. + output = " | ".join(sorted(set([item['word'] for item in definitions]))) # sorted, unique words. # output time. if results == "no_results" or len(definitions) == 0: # NOTHING FOUND. irc.reply("ERROR: '{0}' not defined on UrbanDictionary.".format(optterm))