diff options
author | alezakos <electrovesta@gmail.com> | 2020-08-09 16:48:17 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-09 16:48:17 +0300 |
commit | 65c3752b38fa827f816c63a6f864c60f3ea71f86 (patch) | |
tree | 6f8b25d28688f885de1b0a788e77358fe1dc67d5 /local/utility.py | |
parent | b431c5476514784f97985419323cf4bec9a61500 (diff) | |
parent | 5a0215deac647f52da3e24dc47057af3b132654e (diff) | |
download | supybot_github-65c3752b38fa827f816c63a6f864c60f3ea71f86.tar.gz supybot_github-65c3752b38fa827f816c63a6f864c60f3ea71f86.tar.bz2 supybot_github-65c3752b38fa827f816c63a6f864c60f3ea71f86.zip |
Merge pull request #27 from blast007/python3
Python 3 support
Diffstat (limited to 'local/utility.py')
-rw-r--r-- | local/utility.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/local/utility.py b/local/utility.py index 0393ae7..391051d 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): @@ -72,7 +72,7 @@ def parseBrackets(bracketConfig): if "M" in bracketConfig: return tuple(bracketConfig.split('M', 1)) else: - mid = len(bracketConfig) / 2 + mid = math.floor(len(bracketConfig) / 2) if len(bracketConfig) % 2 == 0: return (bracketConfig[:mid], bracketConfig[mid:]) else: @@ -138,9 +138,9 @@ def getShortURL(longurl): # Temporarily disabled url = longurl try: - req = urllib2.Request("https://git.io/", data) - response = urllib2.urlopen(req) - url = response.info().getheader('Location') + req = urllib.request.Request("https://git.io/", data.encode()) + response = urllib.request.urlopen(req) + url = response.getheader('Location') except IOError as e: # Bad luck log.warning("URL shortening failed with: %s" % (e.message,)) @@ -267,7 +267,7 @@ def _hex_to_rgb(value): def _colourDistance(a, b): # Source: http://www.compuphase.com/cmetric.htm - rmean = (a[0] + b[0]) / 2 + rmean = math.floor((a[0] + b[0]) / 2) red = a[0] - b[0] green = a[1] - b[1] blue = a[2] - b[2] |