Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7787841

Browse files
committed
Hush the nanny.
1 parent 5d64421 commit 7787841

3 files changed

Lines changed: 78 additions & 78 deletions

File tree

Doc/tools/custlib.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@
1212
# Look for *.py files
1313
filelist=glob.glob(os.path.join(dir, '*.py'))
1414
for file in filelist:
15-
path, file = os.path.split(file)
16-
base, ext=os.path.splitext(file)
17-
modules[string.lower(base)]=base
15+
path, file = os.path.split(file)
16+
base, ext=os.path.splitext(file)
17+
modules[string.lower(base)]=base
1818

1919
# Look for shared library files
2020
filelist=(glob.glob(os.path.join(dir, '*.so')) +
21-
glob.glob(os.path.join(dir, '*.sl')) +
22-
glob.glob(os.path.join(dir, '*.o')) )
21+
glob.glob(os.path.join(dir, '*.sl')) +
22+
glob.glob(os.path.join(dir, '*.o')) )
2323
for file in filelist:
24-
path, file = os.path.split(file)
25-
base, ext=os.path.splitext(file)
26-
if base[-6:]=='module': base=base[:-6]
27-
modules[string.lower(base)]=base
24+
path, file = os.path.split(file)
25+
base, ext=os.path.splitext(file)
26+
if base[-6:]=='module': base=base[:-6]
27+
modules[string.lower(base)]=base
2828

2929
# Minor oddity: the types module is documented in libtypes2.tex
3030
if modules.has_key('types'):
@@ -53,7 +53,7 @@
5353
print """\documentstyle[twoside,11pt,myformat]{report}
5454
\\title{Python Library Reference}
5555
\\input{boilerplate}
56-
\\makeindex % tell \\index to actually write the .idx file
56+
\\makeindex % tell \\index to actually write the .idx file
5757
\\begin{document}
5858
\\pagenumbering{roman}
5959
\\maketitle
@@ -69,5 +69,5 @@
6969
print "\\input{lib%s}" % (modname,)
7070

7171
# Write the end
72-
print """\\input{custlib.ind} % Index
72+
print """\\input{custlib.ind} % Index
7373
\\end{document}"""

Doc/tools/indfix.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ def cmp_entries(e1, e2, lower=string.lower):
3030

3131
def dump_entries(write, entries):
3232
if len(entries) == 1:
33-
write(" \\item %s (%s)%s\n" % entries[0])
34-
return
33+
write(" \\item %s (%s)%s\n" % entries[0])
34+
return
3535
write(" \item %s\n" % entries[0][0])
3636
# now sort these in a case insensitive manner:
3737
if len(entries) > 0:
38-
entries.sort(cmp_entries)
38+
entries.sort(cmp_entries)
3939
for xxx, subitem, pages in entries:
40-
write(" \subitem %s%s\n" % (subitem, pages))
40+
write(" \subitem %s%s\n" % (subitem, pages))
4141

4242

4343
breakable_re = re.compile(
@@ -56,31 +56,31 @@ def process(ifn, ofn=None):
5656
match = breakable_re.match
5757
write = ofp.write
5858
while 1:
59-
line = ifp.readline()
60-
if not line:
61-
break
62-
m = match(line)
63-
if m:
64-
entry = m.group(1, 2, 3)
65-
if entries and entries[-1][0] != entry[0]:
66-
dump_entries(write, entries)
67-
entries = []
68-
entries.append(entry)
69-
elif entries:
70-
dump_entries(write, entries)
71-
entries = []
72-
write(line)
73-
else:
74-
write(line)
59+
line = ifp.readline()
60+
if not line:
61+
break
62+
m = match(line)
63+
if m:
64+
entry = m.group(1, 2, 3)
65+
if entries and entries[-1][0] != entry[0]:
66+
dump_entries(write, entries)
67+
entries = []
68+
entries.append(entry)
69+
elif entries:
70+
dump_entries(write, entries)
71+
entries = []
72+
write(line)
73+
else:
74+
write(line)
7575
del write
7676
del match
7777
ifp.close()
7878
data = ofp.getvalue()
7979
ofp.close()
8080
if ofn == "-":
81-
ofp = sys.stdout
81+
ofp = sys.stdout
8282
else:
83-
ofp = open(ofn, "w")
83+
ofp = open(ofn, "w")
8484
ofp.write(data)
8585
ofp.close()
8686

@@ -90,8 +90,8 @@ def main():
9090
outfile = None
9191
opts, args = getopt.getopt(sys.argv[1:], "o:")
9292
for opt, val in opts:
93-
if opt in ("-o", "--output"):
94-
outfile = val
93+
if opt in ("-o", "--output"):
94+
outfile = val
9595
filename = args[0]
9696
outfile = outfile or filename
9797
process(filename, outfile)

Doc/tools/toc2bkm.py

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
\\contentsline\ \{([a-z]*)} # type of section in $1
2424
\{(?:\\numberline\ \{([0-9.A-Z]+)})? # section number
2525
(.*)} # title string
26-
\{(\d+)}$""" # page number
26+
\{(\d+)}$""" # page number
2727

2828
cline_rx = re.compile(cline_re, re.VERBOSE)
2929

@@ -50,34 +50,34 @@ def parse_toc(fp, bigpart=None):
5050
level = bigpart or 'chapter'
5151
lineno = 0
5252
while 1:
53-
line = fp.readline()
54-
if not line:
55-
break
56-
lineno = lineno + 1
57-
m = cline_rx.match(line)
58-
if m:
59-
stype, snum, title, pageno = m.group(1, 2, 3, 4)
60-
title = clean_title(title)
61-
entry = (stype, snum, title, string.atoi(pageno), [])
62-
if stype == level:
63-
toc.append(entry)
64-
else:
53+
line = fp.readline()
54+
if not line:
55+
break
56+
lineno = lineno + 1
57+
m = cline_rx.match(line)
58+
if m:
59+
stype, snum, title, pageno = m.group(1, 2, 3, 4)
60+
title = clean_title(title)
61+
entry = (stype, snum, title, string.atoi(pageno), [])
62+
if stype == level:
63+
toc.append(entry)
64+
else:
6565
if stype not in INCLUDED_LEVELS:
6666
# we don't want paragraphs & subparagraphs
6767
continue
68-
direction = _transition_map[(level, stype)]
69-
if direction == OUTER_TO_INNER:
70-
toc = toc[-1][-1]
71-
stack.insert(0, toc)
72-
toc.append(entry)
73-
else:
74-
for i in range(direction):
75-
del stack[0]
76-
toc = stack[0]
77-
toc.append(entry)
78-
level = stype
79-
else:
80-
sys.stderr.write("l.%s: " + line)
68+
direction = _transition_map[(level, stype)]
69+
if direction == OUTER_TO_INNER:
70+
toc = toc[-1][-1]
71+
stack.insert(0, toc)
72+
toc.append(entry)
73+
else:
74+
for i in range(direction):
75+
del stack[0]
76+
toc = stack[0]
77+
toc.append(entry)
78+
level = stype
79+
else:
80+
sys.stderr.write("l.%s: " + line)
8181
return top
8282

8383

@@ -91,33 +91,33 @@ def clean_title(title):
9191
title = hackscore_rx.sub(r"\\_", title)
9292
pos = 0
9393
while 1:
94-
m = title_rx.search(title, pos)
95-
if m:
96-
start = m.start()
97-
if title[start:start+15] != "\\textunderscore":
98-
title = title[:start] + title[m.end():]
99-
pos = start + 1
100-
else:
101-
break
94+
m = title_rx.search(title, pos)
95+
if m:
96+
start = m.start()
97+
if title[start:start+15] != "\\textunderscore":
98+
title = title[:start] + title[m.end():]
99+
pos = start + 1
100+
else:
101+
break
102102
title = string.translate(title, title_trans, "{}")
103103
return title
104104

105105

106106
def write_toc(toc, fp):
107107
for entry in toc:
108-
write_toc_entry(entry, fp, 0)
108+
write_toc_entry(entry, fp, 0)
109109

110110
def write_toc_entry(entry, fp, layer):
111111
stype, snum, title, pageno, toc = entry
112112
s = "\\pdfoutline goto name{page%03d}" % pageno
113113
if toc:
114-
s = "%s count -%d" % (s, len(toc))
114+
s = "%s count -%d" % (s, len(toc))
115115
if snum:
116-
title = "%s %s" % (snum, title)
116+
title = "%s %s" % (snum, title)
117117
s = "%s {%s}\n" % (s, title)
118118
fp.write(s)
119119
for entry in toc:
120-
write_toc_entry(entry, fp, layer + 1)
120+
write_toc_entry(entry, fp, layer + 1)
121121

122122

123123
def process(ifn, ofn, bigpart=None):
@@ -129,13 +129,13 @@ def main():
129129
bigpart = None
130130
opts, args = getopt.getopt(sys.argv[1:], "c:")
131131
if opts:
132-
bigpart = opts[0][1]
132+
bigpart = opts[0][1]
133133
if not args:
134-
usage()
135-
sys.exit(2)
134+
usage()
135+
sys.exit(2)
136136
for filename in args:
137-
base, ext = os.path.splitext(filename)
138-
ext = ext or ".toc"
137+
base, ext = os.path.splitext(filename)
138+
ext = ext or ".toc"
139139
process(base + ext, base + ".bkm", bigpart)
140140

141141

0 commit comments

Comments
 (0)