Update for python3.
This fixes all of the problems with our kernel scripts, but not
the clang python script problems.
I also removed the updateGitFiles function since that code was
just silently failing any way. I replaced all calls with updateFiles.
Test: Ran script using python2 to verify it still works.
Test: Run script in python3 verifying that it starts to run.
Change-Id: I223a31a8324c59e6bc4067f48a6110361b3e26e8
diff --git a/libc/kernel/tools/kernel.py b/libc/kernel/tools/kernel.py
index b6418a8..6046911 100644
--- a/libc/kernel/tools/kernel.py
+++ b/libc/kernel/tools/kernel.py
@@ -4,7 +4,7 @@
# list here the macros that you know are always defined/undefined when including
# the kernel headers
#
-import sys, cpp, re, os.path, string, time
+import sys, cpp, re, os.path, time
from defaults import *
verboseSearch = 0
@@ -56,7 +56,7 @@
# <mtd/*>
#
re_combined_str=\
- r"^.*<((%s)/[\d\w_\+\.\-/]*)>.*$" % string.join(kernel_dirs,"|")
+ r"^.*<((%s)/[\d\w_\+\.\-/]*)>.*$" % "|".join(kernel_dirs)
re_combined = re.compile(re_combined_str)
@@ -100,7 +100,7 @@
if from_file:
if verboseFind:
- print "=== %s uses %s" % (from_file, header)
+ print("=== %s uses %s" % (from_file, header))
self.headers[header].add(from_file)
def parseFile(self, path, arch=None, kernel_root=None):
@@ -114,7 +114,7 @@
try:
f = open(path, "rt")
except:
- print "!!! can't read '%s'" % path
+ print("!!! can't read '%s'" % path)
return
hasIncludes = False
@@ -125,10 +125,10 @@
break
if not hasIncludes:
- if verboseSearch: print "::: " + path
+ if verboseSearch: print("::: " + path)
return
- if verboseSearch: print "*** " + path
+ if verboseSearch: print("*** " + path)
list = cpp.BlockParser().parseFile(path)
if list:
@@ -205,7 +205,6 @@
if len(kernel_root) > 0 and kernel_root[-1] != "/":
kernel_root += "/"
- #print "using kernel_root %s" % kernel_root
self.archs = archs
self.searched = set(headers)
self.kernel_root = kernel_root
@@ -301,7 +300,7 @@
self.duplicates = False
def parseLine(self,line):
- line = string.strip(line)
+ line = line.strip(line)
# skip empty and comment lines
if len(line) == 0 or line[0] == "#":