Improve PPAPI scripts' Python 3 support
This mostly includes low-hanging fruit.
The scripts still work with Python 2.
There are no intended behaviour changes.
Bug: 941669
Change-Id: Ie950398b967b749f8136b4aea19592b6b50083ed
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1556774
Reviewed-by: Bill Budge <[email protected]>
Commit-Queue: Bill Budge <[email protected]>
Auto-Submit: Raul Tambre <[email protected]>
Cr-Commit-Position: refs/heads/master@{#648792}
diff --git a/ppapi/generators/idl_diff.py b/ppapi/generators/idl_diff.py
index 0d15fe83..7fd83cb8 100755
--- a/ppapi/generators/idl_diff.py
+++ b/ppapi/generators/idl_diff.py
@@ -3,6 +3,8 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+from __future__ import print_function
+
import glob
import os
import subprocess
@@ -37,16 +39,16 @@
def Dump(self):
if not self.was:
- print 'Adding %s' % self.mode
+ print('Adding %s' % self.mode)
elif not self.now:
- print 'Missing %s' % self.mode
+ print('Missing %s' % self.mode)
else:
- print 'Modifying %s' % self.mode
+ print('Modifying %s' % self.mode)
for line in self.was:
- print 'src: >>%s<<' % line
+ print('src: >>%s<<' % line)
for line in self.now:
- print 'gen: >>%s<<' % line
+ print('gen: >>%s<<' % line)
print
#
@@ -234,7 +236,7 @@
filter[nindex] = True
filter[windex] = True
if GetOption('verbose'):
- print "Found %d, %d >>%s<<" % (windex + 1, nindex + 1, wline)
+ print("Found %d, %d >>%s<<" % (windex + 1, nindex + 1, wline))
out = []
for index in range(len(output)):
if not filter[index]:
@@ -259,7 +261,7 @@
last = None
for line in lines:
-# print "LINE=%s" % line
+ #print("LINE=%s" % line)
if not line: continue
elif line[0] == '<':
@@ -282,7 +284,7 @@
was = []
now = []
if ValidChange(change):
- changes.append(change)
+ changes.append(change)
if line == 'END':
break
@@ -315,7 +317,7 @@
name = os.path.split(name)[1]
name = os.path.join(GetOption('gen'), name)
if name not in filenames:
- print 'Missing: %s' % name
+ print('Missing: %s' % name)
for filename in filenames:
gen = filename
@@ -336,18 +338,19 @@
changes = []
if changes:
- print "\n\nDelta between:\n src=%s\n gen=%s\n" % (src, gen)
+ print("\n\nDelta between:\n src=%s\n gen=%s\n" % (src, gen))
for change in changes:
change.Dump()
- print 'Done with %s\n\n' % src
+ print('Done with %s\n\n' % src)
if GetOption('ok'):
open(diff, 'wt').write(output)
if GetOption('halt'):
return 1
else:
- print "\nSAME:\n src=%s\n gen=%s" % (src, gen)
- if input: print ' ** Matched expected diff. **'
- print '\n'
+ print("\nSAME:\n src=%s\n gen=%s" % (src, gen))
+ if input:
+ print(' ** Matched expected diff. **')
+ print('\n')
if __name__ == '__main__':