From 44b626df641f97863370521cdbefebd4c81ec64a Mon Sep 17 00:00:00 2001 From: James Lu Date: Fri, 20 Jan 2017 18:18:06 -0800 Subject: [PATCH] DDG: make _ddgurl() a static method From: https://github.com/jlu5/SupyPlugins/commit/d332e73e48dfa679f3a08786a9dae9da5149b0cc --- plugin.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugin.py b/plugin.py index c4780a168..9ffdfd4e8 100644 --- a/plugin.py +++ b/plugin.py @@ -33,6 +33,7 @@ from supybot.commands import * import supybot.plugins as plugins import supybot.ircutils as ircutils import supybot.callbacks as callbacks +import supybot.log as log try: from supybot.i18n import PluginInternationalization _ = PluginInternationalization('DDG') @@ -59,11 +60,12 @@ class DDG(callbacks.Plugin): """Searches for results on DuckDuckGo.""" threaded = True - def _ddgurl(self, text): + @staticmethod + def _ddgurl(text): # DuckDuckGo has a 'lite' site free of unparseable JavaScript # elements, so we'll use that to our advantage! url = "https://duckduckgo.com/lite?" + urlencode({"q": text}) - self.log.debug("DDG: Using URL %s for search %s", url, text) + log.debug("DDG: Using URL %s for search %s", url, text) data = utils.web.getUrl(url).decode("utf-8") soup = BeautifulSoup(data) # Remove "sponsored link" results