summaryrefslogtreecommitdiffstats
path: root/Doc/tools
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2000-10-07 12:50:05 (GMT)
committerFred Drake <fdrake@acm.org>2000-10-07 12:50:05 (GMT)
commit77878413bae310a1ebb172c83a9484ca55d48b17 (patch)
tree1a1f70fe0213c7c6e58bde33042c3b76a12a6729 /Doc/tools
parent5d64421c23d2f2a3c434e140085c7c81d0b65180 (diff)
downloadcpython-77878413bae310a1ebb172c83a9484ca55d48b17.zip
cpython-77878413bae310a1ebb172c83a9484ca55d48b17.tar.gz
cpython-77878413bae310a1ebb172c83a9484ca55d48b17.tar.bz2
Hush the nanny.
Diffstat (limited to 'Doc/tools')
-rw-r--r--Doc/tools/custlib.py22
-rwxr-xr-xDoc/tools/indfix.py48
-rwxr-xr-xDoc/tools/toc2bkm.py86
3 files changed, 78 insertions, 78 deletions
diff --git a/Doc/tools/custlib.py b/Doc/tools/custlib.py
index 32cb3d2..9958451 100644
--- a/Doc/tools/custlib.py
+++ b/Doc/tools/custlib.py
@@ -12,19 +12,19 @@ for dir in sys.path:
# Look for *.py files
filelist=glob.glob(os.path.join(dir, '*.py'))
for file in filelist:
- path, file = os.path.split(file)
- base, ext=os.path.splitext(file)
- modules[string.lower(base)]=base
+ path, file = os.path.split(file)
+ base, ext=os.path.splitext(file)
+ modules[string.lower(base)]=base
# Look for shared library files
filelist=(glob.glob(os.path.join(dir, '*.so')) +
- glob.glob(os.path.join(dir, '*.sl')) +
- glob.glob(os.path.join(dir, '*.o')) )
+ glob.glob(os.path.join(dir, '*.sl')) +
+ glob.glob(os.path.join(dir, '*.o')) )
for file in filelist:
- path, file = os.path.split(file)
- base, ext=os.path.splitext(file)
- if base[-6:]=='module': base=base[:-6]
- modules[string.lower(base)]=base
+ path, file = os.path.split(file)
+ base, ext=os.path.splitext(file)
+ if base[-6:]=='module': base=base[:-6]
+ modules[string.lower(base)]=base
# Minor oddity: the types module is documented in libtypes2.tex
if modules.has_key('types'):
@@ -53,7 +53,7 @@ modules=mlist
print """\documentstyle[twoside,11pt,myformat]{report}
\\title{Python Library Reference}
\\input{boilerplate}
-\\makeindex % tell \\index to actually write the .idx file
+\\makeindex % tell \\index to actually write the .idx file
\\begin{document}
\\pagenumbering{roman}
\\maketitle
@@ -69,5 +69,5 @@ for modname in mlist:
print "\\input{lib%s}" % (modname,)
# Write the end
-print """\\input{custlib.ind} % Index
+print """\\input{custlib.ind} % Index
\\end{document}"""
diff --git a/Doc/tools/indfix.py b/Doc/tools/indfix.py
index fbf81e6..6e8e911 100755
--- a/Doc/tools/indfix.py
+++ b/Doc/tools/indfix.py
@@ -30,14 +30,14 @@ def cmp_entries(e1, e2, lower=string.lower):
def dump_entries(write, entries):
if len(entries) == 1:
- write(" \\item %s (%s)%s\n" % entries[0])
- return
+ write(" \\item %s (%s)%s\n" % entries[0])
+ return
write(" \item %s\n" % entries[0][0])
# now sort these in a case insensitive manner:
if len(entries) > 0:
- entries.sort(cmp_entries)
+ entries.sort(cmp_entries)
for xxx, subitem, pages in entries:
- write(" \subitem %s%s\n" % (subitem, pages))
+ write(" \subitem %s%s\n" % (subitem, pages))
breakable_re = re.compile(
@@ -56,31 +56,31 @@ def process(ifn, ofn=None):
match = breakable_re.match
write = ofp.write
while 1:
- line = ifp.readline()
- if not line:
- break
- m = match(line)
- if m:
- entry = m.group(1, 2, 3)
- if entries and entries[-1][0] != entry[0]:
- dump_entries(write, entries)
- entries = []
- entries.append(entry)
- elif entries:
- dump_entries(write, entries)
- entries = []
- write(line)
- else:
- write(line)
+ line = ifp.readline()
+ if not line:
+ break
+ m = match(line)
+ if m:
+ entry = m.group(1, 2, 3)
+ if entries and entries[-1][0] != entry[0]:
+ dump_entries(write, entries)
+ entries = []
+ entries.append(entry)
+ elif entries:
+ dump_entries(write, entries)
+ entries = []
+ write(line)
+ else:
+ write(line)
del write
del match
ifp.close()
data = ofp.getvalue()
ofp.close()
if ofn == "-":
- ofp = sys.stdout
+ ofp = sys.stdout
else:
- ofp = open(ofn, "w")
+ ofp = open(ofn, "w")
ofp.write(data)
ofp.close()
@@ -90,8 +90,8 @@ def main():
outfile = None
opts, args = getopt.getopt(sys.argv[1:], "o:")
for opt, val in opts:
- if opt in ("-o", "--output"):
- outfile = val
+ if opt in ("-o", "--output"):
+ outfile = val
filename = args[0]
outfile = outfile or filename
process(filename, outfile)
diff --git a/Doc/tools/toc2bkm.py b/Doc/tools/toc2bkm.py
index c2edea3..45c7ef8 100755
--- a/Doc/tools/toc2bkm.py
+++ b/Doc/tools/toc2bkm.py
@@ -23,7 +23,7 @@ cline_re = r"""^
\\contentsline\ \{([a-z]*)} # type of section in $1
\{(?:\\numberline\ \{([0-9.A-Z]+)})? # section number
(.*)} # title string
-\{(\d+)}$""" # page number
+\{(\d+)}$""" # page number
cline_rx = re.compile(cline_re, re.VERBOSE)
@@ -50,34 +50,34 @@ def parse_toc(fp, bigpart=None):
level = bigpart or 'chapter'
lineno = 0
while 1:
- line = fp.readline()
- if not line:
- break
- lineno = lineno + 1
- m = cline_rx.match(line)
- if m:
- stype, snum, title, pageno = m.group(1, 2, 3, 4)
- title = clean_title(title)
- entry = (stype, snum, title, string.atoi(pageno), [])
- if stype == level:
- toc.append(entry)
- else:
+ line = fp.readline()
+ if not line:
+ break
+ lineno = lineno + 1
+ m = cline_rx.match(line)
+ if m:
+ stype, snum, title, pageno = m.group(1, 2, 3, 4)
+ title = clean_title(title)
+ entry = (stype, snum, title, string.atoi(pageno), [])
+ if stype == level:
+ toc.append(entry)
+ else:
if stype not in INCLUDED_LEVELS:
# we don't want paragraphs & subparagraphs
continue
- direction = _transition_map[(level, stype)]
- if direction == OUTER_TO_INNER:
- toc = toc[-1][-1]
- stack.insert(0, toc)
- toc.append(entry)
- else:
- for i in range(direction):
- del stack[0]
- toc = stack[0]
- toc.append(entry)
- level = stype
- else:
- sys.stderr.write("l.%s: " + line)
+ direction = _transition_map[(level, stype)]
+ if direction == OUTER_TO_INNER:
+ toc = toc[-1][-1]
+ stack.insert(0, toc)
+ toc.append(entry)
+ else:
+ for i in range(direction):
+ del stack[0]
+ toc = stack[0]
+ toc.append(entry)
+ level = stype
+ else:
+ sys.stderr.write("l.%s: " + line)
return top
@@ -91,33 +91,33 @@ def clean_title(title):
title = hackscore_rx.sub(r"\\_", title)
pos = 0
while 1:
- m = title_rx.search(title, pos)
- if m:
- start = m.start()
- if title[start:start+15] != "\\textunderscore":
- title = title[:start] + title[m.end():]
- pos = start + 1
- else:
- break
+ m = title_rx.search(title, pos)
+ if m:
+ start = m.start()
+ if title[start:start+15] != "\\textunderscore":
+ title = title[:start] + title[m.end():]
+ pos = start + 1
+ else:
+ break
title = string.translate(title, title_trans, "{}")
return title
def write_toc(toc, fp):
for entry in toc:
- write_toc_entry(entry, fp, 0)
+ write_toc_entry(entry, fp, 0)
def write_toc_entry(entry, fp, layer):
stype, snum, title, pageno, toc = entry
s = "\\pdfoutline goto name{page%03d}" % pageno
if toc:
- s = "%s count -%d" % (s, len(toc))
+ s = "%s count -%d" % (s, len(toc))
if snum:
- title = "%s %s" % (snum, title)
+ title = "%s %s" % (snum, title)
s = "%s {%s}\n" % (s, title)
fp.write(s)
for entry in toc:
- write_toc_entry(entry, fp, layer + 1)
+ write_toc_entry(entry, fp, layer + 1)
def process(ifn, ofn, bigpart=None):
@@ -129,13 +129,13 @@ def main():
bigpart = None
opts, args = getopt.getopt(sys.argv[1:], "c:")
if opts:
- bigpart = opts[0][1]
+ bigpart = opts[0][1]
if not args:
- usage()
- sys.exit(2)
+ usage()
+ sys.exit(2)
for filename in args:
- base, ext = os.path.splitext(filename)
- ext = ext or ".toc"
+ base, ext = os.path.splitext(filename)
+ ext = ext or ".toc"
process(base + ext, base + ".bkm", bigpart)