Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 17 Jan 2013 04:20:54 +0000 (UTC)
From:      Eitan Adler <eadler@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r245536 - head/tools/tools/notescheck
Message-ID:  <201301170420.r0H4Ks7N092837@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: eadler
Date: Thu Jan 17 04:20:53 2013
New Revision: 245536
URL: http://svnweb.freebsd.org/changeset/base/245536

Log:
  Convert to Python 3
  
  Approved by:	cperciva

Modified:
  head/tools/tools/notescheck/notescheck.py

Modified: head/tools/tools/notescheck/notescheck.py
==============================================================================
--- head/tools/tools/notescheck/notescheck.py	Thu Jan 17 04:20:31 2013	(r245535)
+++ head/tools/tools/notescheck/notescheck.py	Thu Jan 17 04:20:53 2013	(r245536)
@@ -12,9 +12,9 @@ import os.path
 import sys
 
 def usage():
-    print >>sys.stderr, "notescheck <path>"
-    print >>sys.stderr
-    print >>sys.stderr, "Where 'path' is a path to a kernel source tree."
+    print("notescheck <path>", file=sys.stderr)
+    print(file=sys.stderr)
+    print("Where 'path' is a path to a kernel source tree.", file=sys.stderr)
 
 # These files are used to determine if a path is a valid kernel source tree.
 requiredfiles = ['conf/files', 'conf/options', 'conf/NOTES']
@@ -62,9 +62,9 @@ class Option:
             self.type = type
             self.type_location = location
         elif self.type != type:
-            print "WARN: Attempt to change type of %s from %s to %s%s" % \
-                (self.name, self.type, type, location)
-            print "      Previous type set%s" % (self.type_location)
+            print("WARN: Attempt to change type of %s from %s to %s%s" % \
+                (self.name, self.type, type, location))
+            print("      Previous type set%s" % (self.type_location))
 
     def add_define(self, platform):
         self.defines.add(platform)
@@ -93,8 +93,8 @@ class Option:
         if global_platform in self.defines:
             # If the device is defined globally ans is never tested, whine.
             if len(self.tests) == 0:
-                print 'WARN: %s is defined globally but never tested' % \
-                    (self.title())
+                print('WARN: %s is defined globally but never tested' % \
+                    (self.title()))
                 return
             
             # If the device is defined globally and is tested on
@@ -106,25 +106,25 @@ class Option:
 
             # If a device is defined globally but is only tested on a
             # single MD platform, then whine about this.
-            print 'WARN: %s is defined globally but only tested in %s NOTES' % \
-                (self.title(), format_set(self.tests))
+            print('WARN: %s is defined globally but only tested in %s NOTES' % \
+                (self.title(), format_set(self.tests)))
             return
 
         # If an option or device is never tested, whine.
         if len(self.tests) == 0:
-            print 'WARN: %s is defined in %s but never tested' % \
-                (self.title(), format_set(self.defines))
+            print('WARN: %s is defined in %s but never tested' % \
+                (self.title(), format_set(self.defines)))
             return
 
         # The set of MD platforms where this option is defined, but not tested.
         notest = self.defines - self.tests
         if len(notest) != 0:
-            print 'WARN: %s is not tested in %s NOTES' % \
-                (self.title(), format_set(notest))
+            print('WARN: %s is not tested in %s NOTES' % \
+                (self.title(), format_set(notest)))
             return
 
-        print 'ERROR: bad state for %s: defined in %s, tested in %s' % \
-            (self.title(), format_set(self.defines), format_set(self.tests))
+        print('ERROR: bad state for %s: defined in %s, tested in %s' % \
+            (self.title(), format_set(self.defines), format_set(self.tests)))
 
 # This class maintains a dictionary of options keyed by name.
 class Options:
@@ -143,7 +143,7 @@ class Options:
 
     # Warn about inconsistencies
     def warn(self):
-        keys = self.options.keys()
+        keys = list(self.options.keys())
         keys.sort()
         for key in keys:
             option = self.options[key]
@@ -158,11 +158,11 @@ def find_platforms(tree):
     platforms = []
     for file in glob.glob(tree + '*/conf/NOTES'):
         if not file.startswith(tree):
-            print >>sys.stderr, "Bad MD NOTES file %s" %(file)
+            print("Bad MD NOTES file %s" %(file), file=sys.stderr)
             sys.exit(1)
         platforms.append(file[len(tree):].split('/')[0])
     if global_platform in platforms:
-        print >>sys.stderr, "Found MD NOTES file for global platform"
+        print("Found MD NOTES file for global platform", file=sys.stderr)
         sys.exit(1)
     return platforms
 
@@ -224,7 +224,7 @@ def tokenize(line):
     # will contain 'number of quotes' + 1 entries, so it should have
     # an odd number of entries.
     if len(groups) % 2 == 0:
-        print >>sys.stderr, "Failed to tokenize: %s%s" (line, location)
+        print("Failed to tokenize: %s%s" (line, location), file=sys.stderr)
         return []
 
     # String split all the "odd" groups since they are not quoted strings.
@@ -256,7 +256,7 @@ def parse_files_line(line, platform):
 
     # Remaining lines better be optional or mandatory lines.
     if words[1] != 'optional' and words[1] != 'mandatory':
-        print >>sys.stderr, "Invalid files line: %s%s" % (line, location)
+        print("Invalid files line: %s%s" % (line, location), file=sys.stderr)
 
     # Drop the first two words and begin parsing keywords and devices.
     skip = False
@@ -334,7 +334,7 @@ def main(argv=None):
         tree = tree + '/'
     for file in requiredfiles:
         if not os.path.exists(tree + file):
-            print>> sys.stderr, "Kernel source tree missing %s" % (file)
+            print("Kernel source tree missing %s" % (file), file=sys.stderr)
             return 1
     
     platforms = find_platforms(tree)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201301170420.r0H4Ks7N092837>