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.
...
@@ -8,30 +8,11 @@ latex2esis.py script when run over the Python documentation.
__version__
=
'$Revision$'
__version__
=
'$Revision$'
import
errno
import
errno
import
esistools
import
re
import
re
import
string
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
):
def
format_attrs
(
attrs
):
attrs
=
attrs
.
items
()
attrs
=
attrs
.
items
()
attrs
.
sort
()
attrs
.
sort
()
...
@@ -56,13 +37,16 @@ def do_convert(ifp, ofp, knownempties, xml=0):
...
@@ -56,13 +37,16 @@ def do_convert(ifp, ofp, knownempties, xml=0):
if
data
and
data
[
-
1
]
==
"
\n
"
:
if
data
and
data
[
-
1
]
==
"
\n
"
:
data
=
data
[:
-
1
]
data
=
data
[:
-
1
]
if
type
==
"-"
:
if
type
==
"-"
:
data
=
decode
(
data
)
data
=
esistools
.
decode
(
data
)
ofp
.
write
(
data
)
ofp
.
write
(
data
)
if
"
\n
"
in
data
:
if
"
\n
"
in
data
:
lastopened
=
None
lastopened
=
None
knownempty
=
0
knownempty
=
0
lastempty
=
0
lastempty
=
0
elif
type
==
"("
:
elif
type
==
"("
:
if
data
==
"COMMENT"
:
ofp
.
write
(
"<!--"
)
continue
if
knownempty
and
xml
:
if
knownempty
and
xml
:
ofp
.
write
(
"<
%
s
%
s/>"
%
(
data
,
format_attrs
(
attrs
)))
ofp
.
write
(
"<
%
s
%
s/>"
%
(
data
,
format_attrs
(
attrs
)))
else
:
else
:
...
@@ -75,6 +59,9 @@ def do_convert(ifp, ofp, knownempties, xml=0):
...
@@ -75,6 +59,9 @@ def do_convert(ifp, ofp, knownempties, xml=0):
lastempty
=
knownempty
lastempty
=
knownempty
knownempty
=
0
knownempty
=
0
elif
type
==
")"
:
elif
type
==
")"
:
if
data
==
"COMMENT"
:
ofp
.
write
(
"-->"
)
continue
if
xml
:
if
xml
:
if
not
lastempty
:
if
not
lastempty
:
ofp
.
write
(
"</
%
s>"
%
data
)
ofp
.
write
(
"</
%
s>"
%
data
)
...
@@ -87,7 +74,7 @@ def do_convert(ifp, ofp, knownempties, xml=0):
...
@@ -87,7 +74,7 @@ def do_convert(ifp, ofp, knownempties, xml=0):
lastempty
=
0
lastempty
=
0
elif
type
==
"A"
:
elif
type
==
"A"
:
name
,
type
,
value
=
string
.
split
(
data
,
" "
,
2
)
name
,
type
,
value
=
string
.
split
(
data
,
" "
,
2
)
attrs
[
name
]
=
decode
(
value
)
attrs
[
name
]
=
esistools
.
decode
(
value
)
elif
type
==
"e"
:
elif
type
==
"e"
:
knownempty
=
1
knownempty
=
1
...
@@ -101,26 +88,35 @@ def xml_convert(ifp, ofp, knownempties=()):
...
@@ -101,26 +88,35 @@ def xml_convert(ifp, ofp, knownempties=()):
def
main
():
def
main
():
import
getopt
import
sys
import
sys
#
#
convert
=
sgml_convert
convert
=
sgml_convert
if
sys
.
argv
[
1
:]
and
sys
.
argv
[
1
]
in
(
"-x"
,
"--xml"
):
xml
=
0
convert
=
xml_convert
xmldecl
=
0
del
sys
.
argv
[
1
]
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
"dx"
,
[
"declare"
,
"xml"
])
if
len
(
sys
.
argv
)
==
1
:
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
ifp
=
sys
.
stdin
ofp
=
sys
.
stdout
ofp
=
sys
.
stdout
elif
len
(
sys
.
argv
)
==
2
:
elif
len
(
args
)
==
1
:
ifp
=
open
(
sys
.
argv
[
1
])
ifp
=
open
(
args
[
0
])
ofp
=
sys
.
stdout
ofp
=
sys
.
stdout
elif
len
(
sys
.
argv
)
==
3
:
elif
len
(
args
)
==
2
:
ifp
=
open
(
sys
.
argv
[
1
])
ifp
=
open
(
args
[
0
])
ofp
=
open
(
sys
.
argv
[
2
],
"w"
)
ofp
=
open
(
args
[
1
],
"w"
)
else
:
else
:
usage
()
usage
()
sys
.
exit
(
2
)
sys
.
exit
(
2
)
# knownempties is ignored in the XML version
# knownempties is ignored in the XML version
try
:
try
:
if
xml
and
xmldecl
:
opf
.
write
(
'<?xml version="1.0" encoding="iso8859-1"?>
\n
'
)
convert
(
ifp
,
ofp
)
convert
(
ifp
,
ofp
)
except
IOError
,
(
err
,
msg
):
except
IOError
,
(
err
,
msg
):
if
err
!=
errno
.
EPIPE
:
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