diff options
author | Samuel Holland <samuel@sholland.org> | 2018-05-10 15:50:17 -0500 |
---|---|---|
committer | Trygve Aaberge <trygveaa@gmail.com> | 2019-04-08 15:11:57 +0200 |
commit | dbae7898342136c4cd937c93971070c91920fd22 (patch) | |
tree | a739cfe98522e74acf1a8898ef7af9d4e59ae0a4 /wee_slack.py | |
parent | 7fb2a8d377ef45fc5073d971adab1b654104f1ba (diff) | |
download | wee-slack-dbae7898342136c4cd937c93971070c91920fd22.tar.gz |
Miscellaneous Python 3 compatibility fixes
Diffstat (limited to 'wee_slack.py')
-rw-r--r-- | wee_slack.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/wee_slack.py b/wee_slack.py index 1079926..45f3fe0 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -23,6 +23,12 @@ import string from websocket import create_connection, WebSocketConnectionClosedException try: + basestring # Python 2 + unicode +except NameError: # Python 3 + basestring = unicode = str + +try: from urllib.parse import urlencode except ImportError: from urllib import urlencode @@ -30,7 +36,7 @@ except ImportError: # hack to make tests possible.. better way? try: import weechat -except: +except ImportError: pass SCRIPT_NAME = "slack" @@ -4218,7 +4224,8 @@ def dbg(message, level=0, main_buffer=False, fout=False): global debug_string message = "DEBUG: {}".format(message) if fout: - file('/tmp/debug.log', 'a+').writelines(message + '\n') + with open('/tmp/debug.log', 'a+') as log_file: + log_file.writelines(message + '\n') if main_buffer: # w.prnt("", "---------") w.prnt("", "slack: " + message) |