changeset 134:afdef805e9b7

Merge Python 3 branch.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 15 Sep 2020 23:39:49 +0300
parents 3a3958edc813 (current diff) 84ff2570b1fc (diff)
children aa3478847735
files README.txt multimerge.py
diffstat 2 files changed, 13 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/README.txt	Wed Aug 26 11:59:45 2020 +0300
+++ b/README.txt	Tue Sep 15 23:39:49 2020 +0300
@@ -34,7 +34,7 @@
 install the required Google API Python modules ... in Debian 9.x,
 chant the following magic incantations:
 
-$ sudo apt-get install python-pip python-setuptools python-wheel
+$ sudo apt-get install python3-pip python3-setuptools python3-wheel
 
 In older version of Debian, Ubuntu and other distributions package
 names may be different. Most important is to have PIP installed,
@@ -43,7 +43,7 @@
 
 Then, use PIP to install Google API stuff locally for the user ..
 
-$ pip install --upgrade google-api-python-client
+$ pip3 install --upgrade google-api-python-client
 
 If the installation passes without errors, you are good to go.
 At this point, you will need to enable the Calendar API from
--- 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)