aboutsummaryrefslogtreecommitdiffstats
path: root/wee_slack.py
diff options
context:
space:
mode:
authorSamuel Holland <samuel@sholland.org>2018-05-10 15:50:16 -0500
committerTrygve Aaberge <trygveaa@gmail.com>2019-04-08 15:11:57 +0200
commit8192a34aa967662cf16e36913b3c317f99b707d6 (patch)
treec98bb347864667cb41491af6110c3899ae6d0e09 /wee_slack.py
parent4a038e54cf95515f5d02d5dd88d240fe5fb5204e (diff)
downloadwee-slack-8192a34aa967662cf16e36913b3c317f99b707d6.tar.gz
Import urllib classes in a way compatible with Python 3
Try both the old and the new locations.
Diffstat (limited to 'wee_slack.py')
-rw-r--r--wee_slack.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/wee_slack.py b/wee_slack.py
index 281eb8b..68c2c13 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -13,7 +13,6 @@ import json
import sha
import os
import re
-import urllib
import sys
import traceback
import collections
@@ -23,6 +22,11 @@ import string
from websocket import create_connection, WebSocketConnectionClosedException
+try:
+ from urllib.parse import urlencode
+except ImportError:
+ from urllib import urlencode
+
# hack to make tests possible.. better way?
try:
import weechat
@@ -1014,7 +1018,7 @@ class SlackRequest(object):
post_data["token"] = token
self.post_data = post_data
self.params = {'useragent': 'wee_slack {}'.format(SCRIPT_VERSION)}
- self.url = 'https://{}/api/{}?{}'.format(self.domain, request, urllib.urlencode(encode_to_utf8(post_data)))
+ self.url = 'https://{}/api/{}?{}'.format(self.domain, request, urlencode(encode_to_utf8(post_data)))
self.response_id = sha.sha("{}{}".format(self.url, self.start_time)).hexdigest()
self.retries = kwargs.get('retries', 3)
# def __repr__(self):