mirror of
https://github.com/python/cpython.git
synced 2025-11-03 03:22:27 +00:00
#14508: make gprof2html script runnable under python3
Not that I haven't tested it to make sure it works, just that it can run against an empty source file. Initial patch by Popa.Claudiu.
This commit is contained in:
parent
d70846b1b1
commit
776c0df42b
1 changed files with 7 additions and 5 deletions
|
|
@ -19,17 +19,19 @@ trailer = """\
|
||||||
</html>
|
</html>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def add_escapes(input):
|
def add_escapes(filename):
|
||||||
for line in input:
|
with open(filename) as fp:
|
||||||
yield cgi.escape(line)
|
for line in fp:
|
||||||
|
yield cgi.escape(line)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
filename = "gprof.out"
|
filename = "gprof.out"
|
||||||
if sys.argv[1:]:
|
if sys.argv[1:]:
|
||||||
filename = sys.argv[1]
|
filename = sys.argv[1]
|
||||||
outputfilename = filename + ".html"
|
outputfilename = filename + ".html"
|
||||||
input = add_escapes(file(filename))
|
input = add_escapes(filename)
|
||||||
output = file(outputfilename, "w")
|
output = open(outputfilename, "w")
|
||||||
output.write(header % filename)
|
output.write(header % filename)
|
||||||
for line in input:
|
for line in input:
|
||||||
output.write(line)
|
output.write(line)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue