Skip to content

Commit

Permalink
Fix py3 compatibility
Browse files Browse the repository at this point in the history
replace xrange with range and file with open
this change works with py2.7 and 3.4, 3.5
  • Loading branch information
sambler committed Sep 16, 2016
1 parent 67e455b commit 61bcbea
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions share/sphinx/ExtractRstFromSourceCPP.py
Expand Up @@ -146,7 +146,7 @@ def __str__(self):

if buffer_lines[0] != '':
buffer_lines.insert(0, '')
for x in xrange(0, len(buffer_lines)):
for x in range(0, len(buffer_lines)):
buffer_lines[x] = " %s" % buffer_lines[x]
buffer_lines.append('')
buffer = '\n'.join(buffer_lines)
Expand Down Expand Up @@ -181,7 +181,7 @@ def ExtractRst(string, fileh):
indent += 1
# remove indent
bufa = [buf_lines[0]]
for x in xrange(1, len(buf_lines)):
for x in range(1, len(buf_lines)):
bufa.append(buf_lines[x][indent:])
buf = '\n'.join(bufa) + '\n'
##
Expand Down Expand Up @@ -229,7 +229,7 @@ def ExtractRst(string, fileh):
sys.exit(1)

src = open(sys.argv[1]).read()
output = file(sys.argv[2], 'w')
output = open(sys.argv[2], 'w')
ExtractRst(src, output)
output.close()

Expand Down
4 changes: 2 additions & 2 deletions share/sphinx/ExtractRstFromSourceSimple.py
Expand Up @@ -51,7 +51,7 @@ def ExtractRst(inputstr, ofile):
# Make sure that the file name is valid here
if newOutputFile:
ofile.close()
ofile = file(filename, 'w')
ofile = open(filename, 'w')
newOutputFile = True
ofile.write(docstring.strip() + '\n')
else:
Expand All @@ -69,7 +69,7 @@ def ExtractRst(inputstr, ofile):
sys.exit(1)

src = open(sys.argv[1]).read()
output = file(sys.argv[2], 'w')
output = open(sys.argv[2], 'w')
ExtractRst(src, output)
output.close()

Expand Down

0 comments on commit 61bcbea

Please sign in to comment.