Mercurial > hg > gcmultimerge
diff multimerge.py @ 134:afdef805e9b7
Merge Python 3 branch.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 15 Sep 2020 23:39:49 +0300 |
parents | 3a3958edc813 76e49e34b40a |
children | d3135eff1bab |
line wrap: on
line diff
--- a/multimerge.py Wed Aug 26 11:59:45 2020 +0300 +++ b/multimerge.py Tue Sep 15 23:39:49 2020 +0300 @@ -1,13 +1,13 @@ -#!/usr/bin/python +#!/usr/bin/python3 # coding=utf-8 ### ### Google Calendar MultiMerge ### Programmed and designed by Matti 'ccr' Hämäläinen <ccr@tnsp.org> -### (C) Copyright 2016-2017 Tecnic Software productions (TNSP) +### (C) Copyright 2016-2020 Tecnic Software productions (TNSP) ### ### For license information, see file "COPYING". ### -### Python 2.7 <= x < 3 required! Please refer to +### Python 3.7 required! Please refer to ### README.txt for information on other depencies. ### import os @@ -23,7 +23,7 @@ from email.mime.text import MIMEText import httplib2 -import ConfigParser +import configparser as ConfigParser import oauth2client from oauth2client import client @@ -32,6 +32,9 @@ from googleapiclient import discovery +assert sys.version_info >= (3, 7) + + ### ### Misc. helper functions, etc ### @@ -62,12 +65,7 @@ ## to UTF-8 encoding in output here. def gcm_print(smsg): gcm_msgbuf.append(smsg) - if sys.stdout.encoding != None: - rsmsg = smsg.encode(sys.stdout.encoding) - else: - rsmsg = smsg.encode("UTF-8") - - print("{0} | {1}".format(gcm_timestamp(time.localtime()), rsmsg)) + print("{0} | {1}".format(gcm_timestamp(time.localtime()), smsg)) ## Fatal error handler @@ -213,7 +211,7 @@ def __init__(self, src = None): if src == None: self.r = self.g = self.b = 0 - elif isinstance(src, basestring): + elif isinstance(src, str): if len(src) == 6: self.r = int(src[0:2], 16) self.g = int(src[2:4], 16) @@ -256,7 +254,7 @@ bdist_fg = 99999999999 bdist_bg = 99999999999 best_fit = None - for id, col in colors.iteritems(): + for id, col in colors.items(): dist_fg = GCMColor(col["foreground"]).dist(c_fg) dist_bg = GCMColor(col["background"]).dist(c_bg) if dist_fg <= bdist_fg and dist_bg <= bdist_bg: @@ -325,7 +323,7 @@ gcm_debug(4, u"{0} -> '{1}' == {2}".format(name, value, self.mget(name))) def is_str(self, mvalue): - return isinstance(mvalue, basestring) + return isinstance(mvalue, str) def is_string(self, mvalue): return mvalue == None or self.is_str(mvalue)