Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
1d31a36f
Commit
1d31a36f
authored
Oct 07, 2000
by
Fred Drake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Hush the nanny.
parent
87a65f52
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
78 additions
and
78 deletions
+78
-78
Doc/tools/custlib.py
Doc/tools/custlib.py
+11
-11
Doc/tools/indfix.py
Doc/tools/indfix.py
+24
-24
Doc/tools/toc2bkm.py
Doc/tools/toc2bkm.py
+43
-43
No files found.
Doc/tools/custlib.py
View file @
1d31a36f
...
...
@@ -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
"""
\
docume
n
tstyle[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}"""
Doc/tools/indfix.py
View file @
1d31a36f
...
...
@@ -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
(
"
\
i
t
em %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
(
"
\
su
b
item %s%s
\
n
"
%
(
subitem
,
pages
))
write
(
"
\
su
b
item %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)
...
...
Doc/tools/toc2bkm.py
View file @
1d31a36f
...
...
@@ -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
%
03
d
}
" % 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)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment