Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
c1ce320a
Kaydet (Commit)
c1ce320a
authored
Ock 02, 1998
tarafından
Fred Drake
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Script to convert module index data to module index.
üst
0b1337d6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
124 additions
and
0 deletions
+124
-0
modindex.py
Doc/modindex.py
+62
-0
modindex.py
Doc/tools/modindex.py
+62
-0
No files found.
Doc/modindex.py
0 → 100755
Dosyayı görüntüle @
c1ce320a
#! /usr/bin/env python
"""Script to convert raw module index data to module index."""
import
os
import
string
import
sys
def
parse_line
(
input
):
lineno
=
string
.
split
(
input
)[
-
1
]
module
=
input
[:
len
(
input
)
-
(
len
(
lineno
)
+
1
)]
return
module
,
lineno
return
def
cmp_items
((
s1
,
line1
),
(
s2
,
line2
)):
rc
=
cmp
(
string
.
lower
(
s1
),
string
.
lower
(
s2
))
if
rc
==
0
:
# Make the lower-case version come first since the upper-case
# version is usually a helper module for constants and such.
rc
=
cmp
(
s2
,
s1
)
return
rc
def
main
():
if
sys
.
argv
[
1
:]:
infile
=
sys
.
argv
[
1
]
else
:
infile
=
"-"
if
infile
==
"-"
:
ifp
=
sys
.
stdin
ofp
=
sys
.
stdout
sys
.
stdout
=
sys
.
stderr
else
:
ifp
=
open
(
infile
)
base
,
ext
=
os
.
path
.
splitext
(
infile
)
outfile
=
base
+
".ind"
ofp
=
open
(
outfile
,
"w"
)
ofp
.
write
(
"
\\
begin{theindex}
\n\n
"
)
lines
=
ifp
.
readlines
()
for
i
in
range
(
len
(
lines
)):
if
lines
[
i
][
0
]
==
'
\\
'
:
lines
[
i
]
=
'
\1
'
+
lines
[
i
]
lines
=
map
(
parse_line
,
lines
)
lines
.
sort
(
cmp_items
)
prev_letter
=
lines
[
0
][
0
][
0
]
if
prev_letter
==
'
\1
'
:
prev_letter
=
lines
[
0
][
0
][
1
]
prev_letter
=
string
.
lower
(
prev_letter
)
for
module
,
lineno
in
lines
:
if
module
[
0
]
==
'
\1
'
:
module
=
module
[
1
:]
if
string
.
lower
(
module
[
0
])
!=
prev_letter
:
ofp
.
write
(
"
\n
\\
indexspace
\n\n
"
)
prev_letter
=
string
.
lower
(
module
[
0
])
ofp
.
write
(
"
\\
item {
\\
tt
%
s}
%
s
\n
"
%
(
module
,
lineno
))
ofp
.
write
(
"
\n\\
end{theindex}
\n
"
)
if
__name__
==
"__main__"
:
main
()
Doc/tools/modindex.py
0 → 100755
Dosyayı görüntüle @
c1ce320a
#! /usr/bin/env python
"""Script to convert raw module index data to module index."""
import
os
import
string
import
sys
def
parse_line
(
input
):
lineno
=
string
.
split
(
input
)[
-
1
]
module
=
input
[:
len
(
input
)
-
(
len
(
lineno
)
+
1
)]
return
module
,
lineno
return
def
cmp_items
((
s1
,
line1
),
(
s2
,
line2
)):
rc
=
cmp
(
string
.
lower
(
s1
),
string
.
lower
(
s2
))
if
rc
==
0
:
# Make the lower-case version come first since the upper-case
# version is usually a helper module for constants and such.
rc
=
cmp
(
s2
,
s1
)
return
rc
def
main
():
if
sys
.
argv
[
1
:]:
infile
=
sys
.
argv
[
1
]
else
:
infile
=
"-"
if
infile
==
"-"
:
ifp
=
sys
.
stdin
ofp
=
sys
.
stdout
sys
.
stdout
=
sys
.
stderr
else
:
ifp
=
open
(
infile
)
base
,
ext
=
os
.
path
.
splitext
(
infile
)
outfile
=
base
+
".ind"
ofp
=
open
(
outfile
,
"w"
)
ofp
.
write
(
"
\\
begin{theindex}
\n\n
"
)
lines
=
ifp
.
readlines
()
for
i
in
range
(
len
(
lines
)):
if
lines
[
i
][
0
]
==
'
\\
'
:
lines
[
i
]
=
'
\1
'
+
lines
[
i
]
lines
=
map
(
parse_line
,
lines
)
lines
.
sort
(
cmp_items
)
prev_letter
=
lines
[
0
][
0
][
0
]
if
prev_letter
==
'
\1
'
:
prev_letter
=
lines
[
0
][
0
][
1
]
prev_letter
=
string
.
lower
(
prev_letter
)
for
module
,
lineno
in
lines
:
if
module
[
0
]
==
'
\1
'
:
module
=
module
[
1
:]
if
string
.
lower
(
module
[
0
])
!=
prev_letter
:
ofp
.
write
(
"
\n
\\
indexspace
\n\n
"
)
prev_letter
=
string
.
lower
(
module
[
0
])
ofp
.
write
(
"
\\
item {
\\
tt
%
s}
%
s
\n
"
%
(
module
,
lineno
))
ofp
.
write
(
"
\n\\
end{theindex}
\n
"
)
if
__name__
==
"__main__"
:
main
()
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