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
f077b9d6
Kaydet (Commit)
f077b9d6
authored
Ara 01, 1998
tarafından
Fred Drake
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Use esistools, getopt.
üst
3843bae9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
31 deletions
+27
-31
esis2sgml.py
Doc/tools/sgmlconv/esis2sgml.py
+27
-31
No files found.
Doc/tools/sgmlconv/esis2sgml.py
Dosyayı görüntüle @
f077b9d6
...
...
@@ -8,30 +8,11 @@ latex2esis.py script when run over the Python documentation.
__version__
=
'$Revision$'
import
errno
import
esistools
import
re
import
string
_data_rx
=
re
.
compile
(
r"[^\\][^\\]*"
)
def
decode
(
s
):
r
=
''
while
s
:
m
=
_data_rx
.
match
(
s
)
if
m
:
r
=
r
+
m
.
group
()
s
=
s
[
len
(
m
.
group
()):]
elif
s
[
1
]
==
"
\\
"
:
r
=
r
+
"
\\
"
s
=
s
[
2
:]
elif
s
[
1
]
==
"n"
:
r
=
r
+
"
\n
"
s
=
s
[
2
:]
else
:
raise
ValueError
,
"can't handle "
+
`s`
return
r
def
format_attrs
(
attrs
):
attrs
=
attrs
.
items
()
attrs
.
sort
()
...
...
@@ -56,13 +37,16 @@ def do_convert(ifp, ofp, knownempties, xml=0):
if
data
and
data
[
-
1
]
==
"
\n
"
:
data
=
data
[:
-
1
]
if
type
==
"-"
:
data
=
decode
(
data
)
data
=
esistools
.
decode
(
data
)
ofp
.
write
(
data
)
if
"
\n
"
in
data
:
lastopened
=
None
knownempty
=
0
lastempty
=
0
elif
type
==
"("
:
if
data
==
"COMMENT"
:
ofp
.
write
(
"<!--"
)
continue
if
knownempty
and
xml
:
ofp
.
write
(
"<
%
s
%
s/>"
%
(
data
,
format_attrs
(
attrs
)))
else
:
...
...
@@ -75,6 +59,9 @@ def do_convert(ifp, ofp, knownempties, xml=0):
lastempty
=
knownempty
knownempty
=
0
elif
type
==
")"
:
if
data
==
"COMMENT"
:
ofp
.
write
(
"-->"
)
continue
if
xml
:
if
not
lastempty
:
ofp
.
write
(
"</
%
s>"
%
data
)
...
...
@@ -87,7 +74,7 @@ def do_convert(ifp, ofp, knownempties, xml=0):
lastempty
=
0
elif
type
==
"A"
:
name
,
type
,
value
=
string
.
split
(
data
,
" "
,
2
)
attrs
[
name
]
=
decode
(
value
)
attrs
[
name
]
=
esistools
.
decode
(
value
)
elif
type
==
"e"
:
knownempty
=
1
...
...
@@ -101,26 +88,35 @@ def xml_convert(ifp, ofp, knownempties=()):
def
main
():
import
getopt
import
sys
#
convert
=
sgml_convert
if
sys
.
argv
[
1
:]
and
sys
.
argv
[
1
]
in
(
"-x"
,
"--xml"
):
convert
=
xml_convert
del
sys
.
argv
[
1
]
if
len
(
sys
.
argv
)
==
1
:
xml
=
0
xmldecl
=
0
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
"dx"
,
[
"declare"
,
"xml"
])
for
opt
,
arg
in
opts
:
if
opt
in
(
"-d"
,
"--declare"
):
xmldecl
=
1
elif
opt
in
(
"-x"
,
"--xml"
):
xml
=
1
convert
=
xml_convert
if
len
(
args
)
==
0
:
ifp
=
sys
.
stdin
ofp
=
sys
.
stdout
elif
len
(
sys
.
argv
)
==
2
:
ifp
=
open
(
sys
.
argv
[
1
])
elif
len
(
args
)
==
1
:
ifp
=
open
(
args
[
0
])
ofp
=
sys
.
stdout
elif
len
(
sys
.
argv
)
==
3
:
ifp
=
open
(
sys
.
argv
[
1
])
ofp
=
open
(
sys
.
argv
[
2
],
"w"
)
elif
len
(
args
)
==
2
:
ifp
=
open
(
args
[
0
])
ofp
=
open
(
args
[
1
],
"w"
)
else
:
usage
()
sys
.
exit
(
2
)
# knownempties is ignored in the XML version
try
:
if
xml
and
xmldecl
:
opf
.
write
(
'<?xml version="1.0" encoding="iso8859-1"?>
\n
'
)
convert
(
ifp
,
ofp
)
except
IOError
,
(
err
,
msg
):
if
err
!=
errno
.
EPIPE
:
...
...
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