aboutsummaryrefslogtreecommitdiffstats
path: root/local
diff options
context:
space:
mode:
authorScott Wichser <blast007@users.sourceforge.net>2019-01-23 22:38:51 +0000
committerScott Wichser <blast007@users.sourceforge.net>2019-01-23 22:38:51 +0000
commitd85f5f6e634b80416e0cee1c80377978c6f9f6c1 (patch)
treef19e0e6ac524f31b941c7ad30b2347cb8deba532 /local
parentb431c5476514784f97985419323cf4bec9a61500 (diff)
downloadsupybot_github-d85f5f6e634b80416e0cee1c80377978c6f9f6c1.tar.gz
supybot_github-d85f5f6e634b80416e0cee1c80377978c6f9f6c1.tar.bz2
supybot_github-d85f5f6e634b80416e0cee1c80377978c6f9f6c1.zip
Through the use of 2to3 and some manual fixes, the plugin loads successfully on Python 3.
Diffstat (limited to 'local')
-rw-r--r--local/handler/GithubHandler.py40
-rw-r--r--local/testing/ExpectationPluginTestCase.py16
-rw-r--r--local/theme/CompactTheme.py2
-rw-r--r--local/theme/DefaultTheme.py2
-rw-r--r--local/theme/__init__.py7
-rw-r--r--local/utility.py8
6 files changed, 34 insertions, 41 deletions
diff --git a/local/handler/GithubHandler.py b/local/handler/GithubHandler.py
index 0c3a0dc..baf2cf1 100644
--- a/local/handler/GithubHandler.py
+++ b/local/handler/GithubHandler.py
@@ -5,12 +5,12 @@ import json
import time
import random
import socket
-import urllib
-import urllib2
+import urllib.request, urllib.parse, urllib.error
+import urllib.request, urllib.error, urllib.parse
import hashlib
-import urlparse
+import urllib.parse
import threading
-import BaseHTTPServer
+import http.server
from time import strftime
import supybot.log as log
@@ -27,30 +27,30 @@ import supybot.callbacks as callbacks
from ..globals import *
from ..utility import *
-import PingHandler
-import PushHandler
-import WikiHandler
-import IssueHandler
-import StatusHandler
-import TravisHandler
-import MessageHandler
-import NetlifyHandler
-import ReleaseHandler
-import UnknownHandler
-import AppVeyorHandler
-import CreateDeleteHandler
-import IssueCommentHandler
+from . import PingHandler
+from . import PushHandler
+from . import WikiHandler
+from . import IssueHandler
+from . import StatusHandler
+from . import TravisHandler
+from . import MessageHandler
+from . import NetlifyHandler
+from . import ReleaseHandler
+from . import UnknownHandler
+from . import AppVeyorHandler
+from . import CreateDeleteHandler
+from . import IssueCommentHandler
from .. import theme as themes
#TODO: Use a better name and location for this
-class GithubHandler(BaseHTTPServer.BaseHTTPRequestHandler):
+class GithubHandler(http.server.BaseHTTPRequestHandler):
def do_POST(s):
"""Respond to a POST request."""
length = int(s.headers['Content-Length'])
payload = s.rfile.read(length).decode('utf-8')
if 'content-type' not in s.headers or s.headers['content-type'] == 'application/x-www-form-urlencoded':
- post_data = urlparse.parse_qs(payload)
+ post_data = urllib.parse.parse_qs(payload)
data = json.loads(post_data['payload'][0])
else:
data = json.loads(payload)
@@ -81,7 +81,7 @@ class GithubHandler(BaseHTTPServer.BaseHTTPRequestHandler):
# Analyse the URL
i = 0
for part in path:
- part = urllib.unquote(part)
+ part = urllib.parse.unquote(part)
if i == 1 and requireCode:
receivedcode = part
diff --git a/local/testing/ExpectationPluginTestCase.py b/local/testing/ExpectationPluginTestCase.py
index 507fd87..17dd1eb 100644
--- a/local/testing/ExpectationPluginTestCase.py
+++ b/local/testing/ExpectationPluginTestCase.py
@@ -9,7 +9,7 @@ from sys import stdout
from time import sleep
import re
-import urllib
+import urllib.request, urllib.parse, urllib.error
class ExpectationPluginTestCase(PluginTestCase):
plugins = {}
@@ -18,10 +18,10 @@ class ExpectationPluginTestCase(PluginTestCase):
m = self._feedMsg('get ' + query)
manyEs = tcolors.FAIL + 'E' * len(args) + tcolors.ENDC
if m is None:
- print manyEs
- raise TimeoutError, query
+ print(manyEs)
+ raise TimeoutError(query)
if m.args[1].startswith('Error:'):
- print manyEs
+ print(manyEs)
self.fail('%r errored: %s' % (query, m.args[1]))
errors = []
@@ -37,10 +37,10 @@ class ExpectationPluginTestCase(PluginTestCase):
stdout.flush()
if errors:
- print "\n%sWhile describing %s" % (tcolors.FAIL, query)
+ print("\n%sWhile describing %s" % (tcolors.FAIL, query))
for error in errors:
- print "- Failed to assert that %s" % (error,)
- print tcolors.ENDC
+ print("- Failed to assert that %s" % (error,))
+ print(tcolors.ENDC)
self.fail("%i assertions failed while describing %s" % (len(errors), query))
def sendRequest(self, file):
@@ -52,7 +52,7 @@ class ExpectationPluginTestCase(PluginTestCase):
with open('samples/' + file + '.json', 'r') as content_file:
content = content_file.read()
self.files[file] = content
- urllib.urlopen('http://localhost:' + str(self.port), 'payload=' + content)
+ urllib.request.urlopen('http://localhost:' + str(self.port), 'payload=' + content)
def conf(self, name, value):
"""Sets one of the plugin's configuration values"""
diff --git a/local/theme/CompactTheme.py b/local/theme/CompactTheme.py
index 4b1c86b..8675cbd 100644
--- a/local/theme/CompactTheme.py
+++ b/local/theme/CompactTheme.py
@@ -1,4 +1,4 @@
-from DefaultTheme import DefaultTheme
+from .DefaultTheme import DefaultTheme
from ..utility import *
diff --git a/local/theme/DefaultTheme.py b/local/theme/DefaultTheme.py
index dbb8128..8ab0da1 100644
--- a/local/theme/DefaultTheme.py
+++ b/local/theme/DefaultTheme.py
@@ -1,4 +1,4 @@
-from Theme import Theme
+from .Theme import Theme
from ..utility import *
diff --git a/local/theme/__init__.py b/local/theme/__init__.py
index c877d71..e69de29 100644
--- a/local/theme/__init__.py
+++ b/local/theme/__init__.py
@@ -1,7 +0,0 @@
-# Import all files in the current directory
-import os
-for module in os.listdir(os.path.dirname(__file__)):
- if module == '__init__.py' or module[-3:] != '.py':
- continue
- __import__(module[:-3], locals(), globals())
-del module
diff --git a/local/utility.py b/local/utility.py
index 0393ae7..ad63504 100644
--- a/local/utility.py
+++ b/local/utility.py
@@ -2,7 +2,7 @@ import re
import math
import random
import string
-import urllib2
+import urllib.request, urllib.error, urllib.parse
from datetime import datetime, timedelta
import supybot.log as log
@@ -11,7 +11,7 @@ import supybot.world as world
import supybot.ircutils as ircutils
import supybot.registry as registry
-import globals
+from . import globals
def registryValue(plugin, name, channel=None, value=True):
@@ -138,8 +138,8 @@ def getShortURL(longurl):
# Temporarily disabled
url = longurl
try:
- req = urllib2.Request("https://git.io/", data)
- response = urllib2.urlopen(req)
+ req = urllib.request.Request("https://git.io/", data)
+ response = urllib.request.urlopen(req)
url = response.info().getheader('Location')
except IOError as e:
# Bad luck

© 2014-2024 Faster IT GmbH | imprint | privacy policy