mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-13 04:26:33 +03:00
Fixed text docs build on Python 3
Thanks to Arfrever for the patch (ticket #107).
This commit is contained in:
parent
4436fce4c6
commit
291b4ce81f
|
@ -7,7 +7,7 @@ import sys
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
if len(sys.argv) != 3:
|
if len(sys.argv) != 3:
|
||||||
print >>sys.stderr, "usage: %s index.rst text-dir"
|
sys.stderr.write("usage: %s index.rst text-dir\n")
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
_, index, txt_dir = sys.argv
|
_, index, txt_dir = sys.argv
|
||||||
|
@ -18,7 +18,11 @@ def main():
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def iter_file_base(fn):
|
def iter_file_base(fn):
|
||||||
have_line = iter(open(fn)).next
|
f = open(fn)
|
||||||
|
if sys.version_info[0] >= 3:
|
||||||
|
have_line = iter(f).__next__
|
||||||
|
else:
|
||||||
|
have_line = iter(f).next
|
||||||
|
|
||||||
while not have_line().startswith('.. toctree'):
|
while not have_line().startswith('.. toctree'):
|
||||||
pass
|
pass
|
||||||
|
@ -28,7 +32,7 @@ def iter_file_base(fn):
|
||||||
yield os.path.splitext(os.path.basename(fn))[0]
|
yield os.path.splitext(os.path.basename(fn))[0]
|
||||||
|
|
||||||
n = 0
|
n = 0
|
||||||
while 1:
|
while True:
|
||||||
line = have_line()
|
line = have_line()
|
||||||
if line.isspace():
|
if line.isspace():
|
||||||
continue
|
continue
|
||||||
|
@ -37,18 +41,21 @@ def iter_file_base(fn):
|
||||||
n += 1
|
n += 1
|
||||||
yield line.strip()
|
yield line.strip()
|
||||||
|
|
||||||
|
f.close()
|
||||||
|
|
||||||
if n < 5:
|
if n < 5:
|
||||||
# maybe format changed?
|
# maybe format changed?
|
||||||
raise Exception("Not enough files found. Format change in index.rst?")
|
raise Exception("Not enough files found. Format change in index.rst?")
|
||||||
|
|
||||||
def emit(basename, txt_dir):
|
def emit(basename, txt_dir):
|
||||||
for line in open(os.path.join(txt_dir, basename + ".txt")):
|
f = open(os.path.join(txt_dir, basename + ".txt"))
|
||||||
|
for line in f:
|
||||||
line = line.replace("``", "'")
|
line = line.replace("``", "'")
|
||||||
sys.stdout.write(line)
|
sys.stdout.write(line)
|
||||||
|
f.close()
|
||||||
|
|
||||||
# some space between sections
|
# some space between sections
|
||||||
print
|
sys.stdout.write("\n\n")
|
||||||
print
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
Loading…
Reference in New Issue
Block a user