• R/O
  • SSH
  • HTTPS

tortoisesvn: Commit


Commit MetaInfo

Revision29419 (tree)
Time2022-06-15 06:11:12
Authordanielsahlberg

Log Message

Make Python3 compatible

Change Summary

Incremental Difference

--- trunk/Languages/TranslationStatus.py (revision 29418)
+++ trunk/Languages/TranslationStatus.py (revision 29419)
@@ -26,6 +26,8 @@
2626 email address.
2727 """
2828
29+from __future__ import print_function
30+
2931 import sys
3032 import getopt
3133 import os
@@ -55,9 +57,9 @@
5557 stream = sys.stdout
5658 else:
5759 stream = sys.stderr
58- print >> stream, __doc__
60+ print(__doc__, file=stream)
5961 if errmsg:
60- print >> stream, '\nError: %s' % (errmsg)
62+ print('\nError: %s' % (errmsg), file=stream)
6163 sys.exit(2)
6264 sys.exit(0)
6365
@@ -73,10 +75,13 @@
7375 self.from_email_id = '<dev@tortoisesvn.tigris.org>'
7476
7577 def safe_command(self, cmd_and_args, cmd_in=''):
78+ cmd_in = cmd_in.encode(sys.stdin.encoding)
7679 [stdout, stderr] = subprocess.Popen(cmd_and_args,
7780 stdin=subprocess.PIPE,
7881 stdout=subprocess.PIPE,
7982 stderr=subprocess.PIPE).communicate(input=cmd_in)
83+ stdout = stdout.decode(sys.stdout.encoding)
84+ stderr = stderr.decode(sys.stdout.encoding)
8085 return stdout, stderr
8186
8287 def match(self, pattern, string):
@@ -192,6 +197,7 @@
192197 percent = 99
193198 else:
194199 percent = 100 * (trans) / total
200+ percent = round(percent, 1)
195201
196202 if checkAccel:
197203 # return '%2s%% (%s/%s/%s)' % (percent, untrans, fuzzy, accel)
@@ -201,7 +207,7 @@
201207 return '%2s%% (%s)' % (percent, untrans)
202208
203209 def printStatLine(self, Lang, Gui, Doc):
204- print '%-33s: %-19s: %-19s' % (Lang, Gui, Doc)
210+ print('%-33s: %-19s: %-19s' % (Lang, Gui, Doc))
205211
206212 def checkTranslation(self, wrkDir):
207213
@@ -209,13 +215,13 @@
209215 [totDoc, tsDoc] = self.getTotal(wrkDir, fileDoc)
210216
211217 firstline = '==== Translation of %s %s' % (urlTrunk, Sep75)
212- print ''
213- print firstline[0:75]
218+ print('')
219+ print(firstline[0:75])
214220 self.printStatLine('', 'User interface', 'Manuals')
215221 self.printStatLine('Total strings', totGui, totDoc)
216222 # self.printStatLine('Language', 'Status (un/fu/ma)', 'Status (un/fu)')
217223 self.printStatLine('Language', 'Status (un/ma)', 'Status (un)')
218- print Sep75
224+ print(Sep75)
219225
220226 csvReader = csv.DictReader(
221227 open(langList), langFields, delimiter=';', quotechar='"')
@@ -232,7 +238,7 @@
232238 statusDoc = self.checkStatus(
233239 wrkDir, langCC, fileDoc, totDoc, False)
234240
235- if statusGui != 'NONE' or statusDoc != 'NONE':
241+ if statusGui != '---' or statusDoc != '----':
236242 langName = row['LangName'].strip()
237243 langName = langName + ' (' + langCC + ')'
238244 self.printStatLine(langName, statusGui, statusDoc)
@@ -242,7 +248,7 @@
242248 def createReport(self):
243249 [info_out, info_err] = self.safe_command(['svn', 'info'])
244250 if info_err:
245- print >> sys.stderr, '\nError: %s' % (info_err)
251+ print('\nError: %s' % (info_err), file=sys.stderr)
246252 sys.exit(0)
247253
248254 # Try different matches for older and newer svn clients
@@ -257,10 +263,10 @@
257263
258264 self.checkTranslation(wrkDir)
259265
260- print Sep75
261-# print 'Status: fu=fuzzy - un=untranslated - ma=missing accelerator keys'
262- print 'Status: un=untranslated - ma=missing accelerator keys'
263- print Sep75
266+ print(Sep75)
267+# print('Status: fu=fuzzy - un=untranslated - ma=missing accelerator keys')
268+ print('Status: un=untranslated - ma=missing accelerator keys')
269+ print(Sep75)
264270
265271 # Clean up the tmp folder
266272 for root, dirs, files in os.walk('tmp', topdown=False):
@@ -279,7 +285,7 @@
279285 ['help',
280286 'to-email-id=',
281287 ])
282- except getopt.GetoptError, msg:
288+ except getopt.GetoptError as msg:
283289 usage_and_exit(msg)
284290
285291 to_email_id = None
@@ -293,13 +299,13 @@
293299
294300 [info_out, info_err] = report.safe_command(['svnversion', wrkDir])
295301 if info_err:
296- print >> sys.stderr, '\nError: %s' % (info_err)
302+ print('\nError: %s' % (info_err), file=sys.stderr)
297303 sys.exit(0)
298304
299305 wcrev = re.sub('[MS]', '', info_out).strip()
300306
301307 subject = 'TortoiseSVN translation status report for r%s' % (wcrev)
302- print subject
308+ print(subject)
303309
304310 report.createReport()
305311
Show on old repository browser