diff --git a/DDG/config.py b/DDG/config.py index 2e8b3da..8f642f6 100644 --- a/DDG/config.py +++ b/DDG/config.py @@ -36,7 +36,8 @@ try: except: # Placeholder that allows to run the plugin on a bot # without the i18n module - _ = lambda x:x + _ = lambda x: x + def configure(advanced): # This will be called by supybot to configure this module. advanced is diff --git a/DDG/plugin.py b/DDG/plugin.py index 4522acb..c0d7886 100644 --- a/DDG/plugin.py +++ b/DDG/plugin.py @@ -39,18 +39,20 @@ try: except ImportError: # Placeholder that allows to run the plugin on a bot # without the i18n module - _ = lambda x:x + _ = lambda x: x -try: # Python 3 + +try: # Python 3 from urllib.parse import urlencode -except ImportError: # Python 2 +except ImportError: # Python 2 from urllib import urlencode try: from bs4 import BeautifulSoup except ImportError: raise ImportError("Beautiful Soup 4 is required for this plugin: get it" - " at http://www.crummy.com/software/BeautifulSoup/bs4/doc/" - "#installing-beautiful-soup") + " at http://www.crummy.com/software/BeautifulSoup/bs4" + "/doc/#installing-beautiful-soup") + class DDG(callbacks.Plugin): """Searches for results on DuckDuckGo.""" @@ -60,7 +62,7 @@ class DDG(callbacks.Plugin): """ Searches for on DuckDuckGo (web search).""" - url = "https://duckduckgo.com/lite?" + urlencode({"q":text}) + url = "https://duckduckgo.com/lite?" + urlencode({"q": text}) try: data = utils.web.getUrl(url).decode("utf-8") except utils.web.Error as e: @@ -75,7 +77,8 @@ class DDG(callbacks.Plugin): continue try: # 1) Get a result snippet. - snippet = res.parent.next_sibling.next_sibling.find_all("td")[-1] + snippet = res.parent.next_sibling.next_sibling.\ + find_all("td")[-1] # 2) Fetch the result link. link = res.a.get('href') snippet = snippet.text.strip() diff --git a/DDG/test.py b/DDG/test.py index 3eea5c2..abfed70 100644 --- a/DDG/test.py +++ b/DDG/test.py @@ -30,11 +30,13 @@ from supybot.test import * + class DDGTestCase(PluginTestCase): plugins = ('DDG',) def testSearch(self): - self.assertRegexp('ddg search wikipedia', 'Wikipedia.*? - .*?https?\:\/\/') + self.assertRegexp( + 'ddg search wikipedia', 'Wikipedia.*? - .*?https?\:\/\/') # vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: diff --git a/FML/config.py b/FML/config.py index 79781b8..9ab1b97 100644 --- a/FML/config.py +++ b/FML/config.py @@ -36,7 +36,8 @@ try: except: # Placeholder that allows to run the plugin on a bot # without the i18n module - _ = lambda x:x + _ = lambda x: x + def configure(advanced): # This will be called by supybot to configure this module. advanced is diff --git a/FML/plugin.py b/FML/plugin.py index adca2e5..15e628b 100644 --- a/FML/plugin.py +++ b/FML/plugin.py @@ -41,7 +41,8 @@ try: except ImportError: # Placeholder that allows to run the plugin on a bot # without the i18n module - _ = lambda x:x + _ = lambda x: x + class FML(callbacks.Plugin): """Displays entries from fmylife.com.""" @@ -51,7 +52,8 @@ class FML(callbacks.Plugin): """requires no arguments. Displays a random entry from fmylife.com.""" - url = 'http://api.betacie.com/view/random?key=4be9c43fc03fe&language=en' + url = ('http://api.betacie.com/view/random?key=4be9c43fc03fe' + '&language=en') try: data = utils.web.getUrl(url) except utils.web.Error as e: @@ -63,9 +65,10 @@ class FML(callbacks.Plugin): text = tree.find('text').text fmlid = tree.attrib['id'] url = tree.find('short_url').text - votes = ircutils.bold("[Agreed: %s / Deserved: %s]" % \ - (tree.find('agree').text, tree.find('deserved').text)) - s = format('\x02#%i [%s]\x02: %s - %s %u', fmlid, + votes = ircutils.bold("[Agreed: %s / Deserved: %s]" % + (tree.find('agree').text, + tree.find('deserved').text)) + s = format('\x02#%i [%s]\x02: %s - %s %u', fmlid, category, text, votes, url) irc.reply(s) fml = wrap(fml) diff --git a/FML/test.py b/FML/test.py index 93cbdca..aeaa46e 100644 --- a/FML/test.py +++ b/FML/test.py @@ -30,6 +30,7 @@ from supybot.test import * + class FMLTestCase(PluginTestCase): plugins = ('FML',) diff --git a/Isup/config.py b/Isup/config.py index bfab6c2..ce3b265 100644 --- a/Isup/config.py +++ b/Isup/config.py @@ -36,7 +36,7 @@ try: except: # Placeholder that allows to run the plugin on a bot # without the i18n module - _ = lambda x:x + _ = lambda x: x def configure(advanced): # This will be called by supybot to configure this module. advanced is diff --git a/Isup/plugin.py b/Isup/plugin.py index cc89990..4de5068 100644 --- a/Isup/plugin.py +++ b/Isup/plugin.py @@ -39,35 +39,37 @@ try: except ImportError: # Placeholder that allows to run the plugin on a bot # without the i18n module - _ = lambda x:x + _ = lambda x: x + class Isup(callbacks.Plugin): """Provides a simple command to check whether a website is up or down (using isup.me).""" - + def _getreply(self, url): data = utils.web.getUrl("http://isup.me/%s" % url).decode("utf-8") if "It's just you." in data: reply = 'up' - elif "looks down from here" in data: + elif "looks down from here" in data: reply = 'down' elif "doesn't look like a site" in data: reply = 'unknown' elif "and still think we're down" in data: - return "Haven't you got anything better to do than look for hidden special replies? :P" - else: + return ("Haven't you got anything better to do than look for " + "hidden special replies? :P") + else: return "An error occurred, please check your URL and try again." try: return self.registryValue("replies." + reply) % url except TypeError: return self.registryValue("replies." + reply) - + def check(self, irc, msg, args, url): """ Check whether a website is up or down using isup.me.""" - try: + try: url = url.split("://")[1] - except: + except: pass irc.reply(self._getreply(url)) check = wrap(check, ['something']) diff --git a/Isup/test.py b/Isup/test.py index a6eb470..9beb209 100644 --- a/Isup/test.py +++ b/Isup/test.py @@ -30,6 +30,7 @@ from supybot.test import * + class IsupTestCase(PluginTestCase): plugins = ('Isup',)