summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorAnthony King <anthonydking@slimroms.net>2015-10-31 15:40:11 -0400
committerTom Powell <zifnab@zifnab06.net>2016-01-04 10:51:19 -0800
commitc66c9aec6b4cbae1f1710e914a66fad53b9ec683 (patch)
tree8a670cda5d10bf0680567e24c24291fbdc2010ad /tools
parent3e087e10d1359ce11a46da2f71ae1e72be885394 (diff)
downloadbuild-c66c9aec6b4cbae1f1710e914a66fad53b9ec683.zip
build-c66c9aec6b4cbae1f1710e914a66fad53b9ec683.tar.gz
build-c66c9aec6b4cbae1f1710e914a66fad53b9ec683.tar.bz2
py3: parsedeps
Change-Id: I7a1df87da284e771eeca65c44ab91f88aaab5c80
Diffstat (limited to 'tools')
-rwxr-xr-xtools/parsedeps.py31
1 files changed, 17 insertions, 14 deletions
diff --git a/tools/parsedeps.py b/tools/parsedeps.py
index 32d8ad7..9a4fc8e 100755
--- a/tools/parsedeps.py
+++ b/tools/parsedeps.py
@@ -1,6 +1,8 @@
#!/usr/bin/env python
# vim: ts=2 sw=2
+from __future__ import print_function
+
import optparse
import re
import sys
@@ -49,7 +51,9 @@ class Dependencies:
return None
def __iter__(self):
- return self.lines.iteritems()
+ if hasattr(self.lines, 'iteritems'):
+ return self.lines.iteritems()
+ return iter(self.lines.items())
def trace(self, tgt, prereq):
self.__visit = self.__visit + 1
@@ -73,9 +77,9 @@ class Dependencies:
return result
def help():
- print "Commands:"
- print " dep TARGET Print the prerequisites for TARGET"
- print " trace TARGET PREREQ Print the paths from TARGET to PREREQ"
+ print("Commands:")
+ print(" dep TARGET Print the prerequisites for TARGET")
+ print(" trace TARGET PREREQ Print the paths from TARGET to PREREQ")
def main(argv):
@@ -87,7 +91,7 @@ def main(argv):
deps = Dependencies()
filename = args[0]
- print "Reading %s" % filename
+ print("Reading %s" % filename)
if True:
f = open(filename)
@@ -106,7 +110,7 @@ def main(argv):
deps.add(tgt, prereq)
f.close()
- print "Read %d dependencies. %d targets." % (deps.count, len(deps.lines))
+ print("Read %d dependencies. %d targets." % (deps.count, len(deps.lines)))
while True:
line = raw_input("target> ")
if not line.strip():
@@ -118,12 +122,12 @@ def main(argv):
d = deps.get(tgt)
if d:
for prereq in d.prereqs:
- print prereq.tgt
+ print(prereq.tgt)
elif len(split) == 3 and cmd == "trace":
tgt = split[1]
prereq = split[2]
if False:
- print "from %s to %s" % (tgt, prereq)
+ print("from %s to %s" % (tgt, prereq))
trace = deps.trace(tgt, prereq)
if trace:
width = 0
@@ -134,10 +138,10 @@ def main(argv):
for g in trace:
for t in g:
if t.pos:
- print t.tgt, " " * (width-len(t.tgt)), " #", t.pos
+ print(t.tgt, " " * (width-len(t.tgt)), " #", t.pos)
else:
- print t.tgt
- print
+ print(t.tgt)
+ print()
else:
help()
@@ -145,7 +149,6 @@ if __name__ == "__main__":
try:
main(sys.argv)
except KeyboardInterrupt:
- print
+ print()
except EOFError:
- print
-
+ print()