[Commits] [SCM] claws branch, master, updated. 3.17.4-90-ged7643486

mones at claws-mail.org mones at claws-mail.org
Mon Jan 20 20:18:14 CET 2020


The branch, master has been updated
       via  ed7643486d1e3af87b3b820a5833f4e8f10d551e (commit)
       via  30dc4ad1fe9f0def6f889cc62e1860f3bf937c15 (commit)
       via  d4c8692df6856c43fbcc3e59addf042cec79c988 (commit)
       via  03263817988b61341338d34c50de205d00f7cd14 (commit)
      from  7634582edc11fdf57b2023904a9af079614f3982 (commit)

Summary of changes:
 tools/eud2gc.py           | 12 +++++------
 tools/gitlog2changelog.py | 14 ++++++------
 tools/tbird2claws.py      | 11 +++++-----
 tools/vcard2xml.py        | 54 +++++++++++++++++++++++------------------------
 4 files changed, 45 insertions(+), 46 deletions(-)


- Log -----------------------------------------------------------------
commit ed7643486d1e3af87b3b820a5833f4e8f10d551e
Author: Ricardo Mones <ricardo at mones.org>
Date:   Mon Jan 20 20:17:30 2020 +0100

    Python 2 EOL: migrate vcard2xml.py to Python 3

diff --git a/tools/vcard2xml.py b/tools/vcard2xml.py
index dd6b6146b..473c85b61 100755
--- a/tools/vcard2xml.py
+++ b/tools/vcard2xml.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # -*- coding: latin-1 -*-
 """
 
@@ -31,7 +31,7 @@ import string
 import sys
 import time
 import os
-import StringIO
+from io import StringIO
 
 keywds = ('x-evolution-file-as','fn', 'n','email;internet','nickname', 'url', 'org')
 
@@ -112,13 +112,13 @@ def readVCARD (buffer) :
 	while r and bgn < 0 :
 		r = buffer.readline()
 		if len (r)  == 0 : return dict()
-		if string.find('begin',string.lower(string.strip(r))) :
+		if r.strip().lower().find('begin') :
 			bgn = 1
 	while r and end < 0 :
 		r = buffer.readline()
-		s = string.split(string.lower(string.strip(r)),':')
- 		if s[0] <> '' :
-			if d.has_key(s[0]) :
+		s = r.strip().lower().split(':')
+		if s[0] != '' :
+			if s[0] in d :
 				d[s[0]].append(s[1])
 			elif len(s) > 1:
 				d[s[0]] = [s[1]]	
@@ -143,7 +143,7 @@ def writeXMLREPR (vcard,file,uid) :
 	if len (vcard.keys()) == 0 : return
 	item = vcard.get(keywds[2]);
 	if item:
-		name = string.split(item[0],';')
+		name = item[0].split(';')
 	else:
 		""" version 3.0 n ?"""
 		name = findName(vcard)
@@ -158,7 +158,7 @@ def writeXMLREPR (vcard,file,uid) :
 	elif len(name) ==1 :
 		fn = name[0]
 	
-	if vcard.has_key(keywds[4]) :
+	if keywds[4] in vcard :
 		nick = vcard.get(keywds[4])[0]
 	if len(vcard.get(keywds[1])[0]) :
 		cn = vcard.get(keywds[1])[0]
@@ -195,29 +195,29 @@ def convert (in_f, o_f, name='INBOX') :
 	uid = [int(time.time())]
 	
 	try :
-		print 'proccessing...\n'
+		print('proccessing...\n')
 		o_f.write('<?xml version="1.0" encoding="ISO-8859-1" ?>\n<address-book name="'+name+'" >\n');
 		
 		buf = normalizeLongLines(in_f)
-		buffer = StringIO.StringIO(buf)
+		buffer = StringIO(buf)
 		while len(d.keys()) > 0 :
 			d = readVCARD(buffer)
 			writeXMLREPR (d, o_f, uid)
 			uid[0] = uid [0]+1
 		
 		o_f.write('\n</address-book>')
-		print 'finished processing...\n'
-	except IOError, err :
-		print 'Caught an IOError : ',err,'\t ABORTING!!!'
+		print('finished processing...\n')
+	except IOError as err :
+		print('Caught an IOError : ',err,'\t ABORTING!!!')
 		raise err
 
 #################################################################################################
 
 def execute () :
-	if len(sys.argv) <> 3 and len(sys.argv) <> 2 :
-		print str("\nUsage: vcard2xml.py  source_file [destination_file]\n\n" +
+	if len(sys.argv) != 3 and len(sys.argv) != 2 :
+		print(str("\nUsage: vcard2xml.py  source_file [destination_file]\n\n" +
 		'\tWhen only <source_file> is specified will overwrite the existing addressbook.\n'+
-		'\tWhen both arguments are suplied will create a new additional addressbook named \n\tas the destination file.'+'\n\tNOTE: in both cases the Claws Mail must be closed and ran at least once.\n\n')
+		'\tWhen both arguments are suplied will create a new additional addressbook named \n\tas the destination file.'+'\n\tNOTE: in both cases the Claws Mail must be closed and ran at least once.\n\n'))
 		sys.exit(1)
 
 	in_file = None
@@ -230,8 +230,8 @@ def execute () :
 
 	try :
 		in_file = open(sys.argv[1])
-	except IOError, e:
-		print 'Could not open input file <',sys.argv[1],'>  ABORTING'
+	except IOError as e:
+		print('Could not open input file <',sys.argv[1],'>  ABORTING')
 		sys.exit(1)
 
 	if len(sys.argv) == 2 :
@@ -246,16 +246,16 @@ def execute () :
 			os.rename(path_to_out+out_file, path_to_out+out_file+'.tmp')
 			out_file = open(path_to_out+out_file,'w')
 			convert(in_file, out_file)
-		except Exception, e:
+		except Exception as e:
 			got_ex = 1
-			print 'got exception: ', e
+			print('got exception: ', e)
 	else :
 		try :
 			os.rename(path_to_out+adr_idx, path_to_out+adr_idx+'.tmp')
 			tmp_adr_idx_file = open(path_to_out+adr_idx+'.tmp')
 			adr_idx_file = open(path_to_out+adr_idx,'w')
-		except Exception, e :
-			print 'Could not open <', path_to_out+adr_idx,'> file. Make sure you started Claws Mail at least once.'
+		except Exception as e :
+			print('Could not open <', path_to_out+adr_idx,'> file. Make sure you started Claws Mail at least once.')
 			sys.exit(1)
 		try :
 			out_file = open(path_to_out+sys.argv[2],'w')
@@ -268,14 +268,14 @@ def execute () :
 				else :
 					adr_idx_file.write(l)
 				l = tmp_adr_idx_file.readline()
-		except Exception, e:
+		except Exception as e:
 			got_ex = 1
-			print 'got exception: ', e
+			print('got exception: ', e)
 	
 
 	if got_ex :
 		#clean up the mess
-		print 'got exception, cleaning up the mess... changed files will be restored...\n'
+		print('got exception, cleaning up the mess... changed files will be restored...\n')
 		if adr_idx_file :
 			adr_idx_file.close()
 		if out_file :
@@ -290,7 +290,7 @@ def execute () :
 				
 	else :
 		#closing all and moving temporary data into place
-		print 'closing open files...\n'
+		print('closing open files...\n')
 		in_file.close()
 		out_file.close()	
 		if len(sys.argv) == 3 :
@@ -301,7 +301,7 @@ def execute () :
 			adr_idx_file.close()
 		if tmp_adr_idx_file :
 			tmp_adr_idx_file.close()
-		print 'done!'
+		print('done!')
 		
 
 if __name__ == '__main__':

commit 30dc4ad1fe9f0def6f889cc62e1860f3bf937c15
Author: Ricardo Mones <ricardo at mones.org>
Date:   Mon Jan 20 20:15:32 2020 +0100

    Python 2 EOL: migrate gitlog2changelog.py to Python 3

diff --git a/tools/gitlog2changelog.py b/tools/gitlog2changelog.py
index fdbc178cc..e331a5b66 100755
--- a/tools/gitlog2changelog.py
+++ b/tools/gitlog2changelog.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python2
+#!/usr/bin/env python3
 # Copyright 2008 Marcus D. Hanwell <marcus at cryos.org>
 # Adapted for Claws Mail - Copyright 2013 Colin Leroy <colin at colino.net>
 # Distributed under the terms of the GNU General Public License v2 or later
@@ -40,7 +40,7 @@ prevAuthorLine = ""
 # The main part of the loop
 for line in fin:
     # The commit line marks the start of a new commit object.
-    if re.match('^commit', line) >= 0:
+    if re.match('^commit', line):
         # Start all over again...
         authorFound = False
         dateFound = False
@@ -55,24 +55,24 @@ for line in fin:
         commit = commit[0:len(commit)-1]
         continue
     # Match the author line and extract the part we want
-    elif re.match('^Author:', line) >=0:
+    elif re.match('^Author:', line):
         authorList = re.split(': ', line, 1)
         author = re.split('<', authorList[1], 1)[0]
         author = "[" + author[0:len(author)-1]+"]"
         authorFound = True
         continue
     # Match the date line
-    elif re.match('^Date:', line) >= 0:
+    elif re.match('^Date:', line):
         dateList = re.split(':   ', line, 1)
         date = dateList[1]
         date = date[0:len(date)-1]
         dateFound = True
         continue
     # The svn-id lines are ignored
-    elif re.match('    git-svn-id:', line) >= 0:
+    elif re.match('    git-svn-id:', line):
         continue
     # The sign off line is ignored too
-    elif re.search('Signed-off-by', line) >= 0:
+    elif re.search('Signed-off-by', line) != None:
         continue
     # Extract the actual commit message for this commit
     elif authorFound & dateFound & messageFound == False:
@@ -90,7 +90,7 @@ for line in fin:
             else:
                 message = message + " " + line.strip()
     # If this line is hit all of the files have been stored for this commit
-    elif re.search('file(s)? changed', line) >= 0:
+    elif re.search('file(s)? changed', line) != None:
         filesFound = True
         continue
     # Collect the files for this commit. FIXME: Still need to add +/- to files

commit d4c8692df6856c43fbcc3e59addf042cec79c988
Author: Ricardo Mones <ricardo at mones.org>
Date:   Mon Jan 20 20:13:54 2020 +0100

    Python 2 EOL: migrate tbird2claws.py to Python 3

diff --git a/tools/tbird2claws.py b/tools/tbird2claws.py
index aee01c7e2..8cf2bb25f 100755
--- a/tools/tbird2claws.py
+++ b/tools/tbird2claws.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python3
 
 # Script name : tbird2claws.py
 # Script purpose : Integrate a Thunderbird folder tree to Claws Mail
@@ -12,12 +12,11 @@
 #Best way to use it is to go to inside yout Thunderbird
 #root mailfolder directory and invoke it as:
 
-#<path>\python2.4 <path>\tbird2claws.py . <path to
-#claws-mail>\Mail
+#<path>\python3 <path>\tbird2claws.py . <path to claws-mail>\Mail
 
 import os
 import sys
-from imp import reload
+import importlib
 
 __author__ = 'Rodrigo Senra <rsenra at acm.org>'
 __date__ =  '2005-03-23'
@@ -33,7 +32,7 @@ The script receives two parameters from command-line:
 Best way to use it is to go to inside your Thunderbird
 root mailfolder directory and invoke it as:
 
-  <path>\python2.4 <path>\tbird2syl.py . <path to claws mail>\Mail
+  <path>\python3 <path>\tbird2claws.py . <path to claws mail>\Mail
 
 This idiom will avoid the creation of the folder Thunderbird inside
 your Claws Mail folder tree.
@@ -129,6 +128,6 @@ if __name__=='__main__':
         print (__doc__)
     else:
         if sys.version[0] == '2':
-            reload(sys)
+            importlib.reload(sys)
             sys.setdefaultencoding('utf8')
         convert_tree(sys.argv[1], sys.argv[2])

commit 03263817988b61341338d34c50de205d00f7cd14
Author: Ricardo Mones <ricardo at mones.org>
Date:   Mon Jan 20 20:09:50 2020 +0100

    Python 2 EOL: migrate eud2gc.py to Python 3
    
    https://mail.python.org/pipermail/python-dev/2018-March/152348.html

diff --git a/tools/eud2gc.py b/tools/eud2gc.py
index 3e5927b6c..5794e3b00 100755
--- a/tools/eud2gc.py
+++ b/tools/eud2gc.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python3
 
 import string, sys
 
@@ -9,7 +9,7 @@ def lReadEfile(sFileName):
 	except:
 		print ('Error opening %s' %sFileName)
 	lLines = []	
-	lLines = string.splitfields(sLines, '\n')	
+	lLines = sLines.split('\n')
 	return lLines
 		
 
@@ -17,13 +17,13 @@ def dElines2Dict(lElines):
 	dAliases = {}
 	for sEntry in lElines:
 		if '"' in sEntry:
-			lChunks = string.splitfields(sEntry, '"')
+			lChunks = sEntry.split('"')
 		else:
-			lChunks = string.splitfields(sEntry, ' ')
-		if lChunks[0] <> 'alias':
+			lChunks = sEntry.split(' ')
+		if lChunks[0] != 'alias':
 			print ('ignoring invalid line: %s' %sEntry)
 		else:
-			sAdresses = string.joinfields(lChunks[2:], ',')
+			sAdresses = lChunks[2:].join(',')
 			print ('Entry added: %s %s' %(lChunks[1],sEntry))
 			dAliases[lChunks[1]]=sAdresses
 	return dAliases

-----------------------------------------------------------------------


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list