1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-03 12:35:02 +00:00

Convert to Python 3

Approved by:	cperciva
This commit is contained in:
Eitan Adler 2013-01-17 04:20:53 +00:00
parent 76d916f1f5
commit 6b1897b2ad
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=245536

View File

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