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
63de8f6d
Commit
63de8f6d
authored
Nov 23, 1998
by
Fred Drake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moving to sgmlconv/ subdir.
parent
bbd7509d
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
468 deletions
+0
-468
Doc/tools/esis2sgml.py
Doc/tools/esis2sgml.py
+0
-131
Doc/tools/latex2esis.py
Doc/tools/latex2esis.py
+0
-337
No files found.
Doc/tools/esis2sgml.py
deleted
100755 → 0
View file @
bbd7509d
#! /usr/bin/env python
"""Convert ESIS events to SGML or XML markup.
This is limited, but seems sufficient for the ESIS generated by the
latex2esis.py script when run over the Python documentation.
"""
__version__
=
'$Revision$'
import
errno
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
()
s
=
''
for
name
,
value
in
attrs
:
s
=
'%s %s="%s"'
%
(
s
,
name
,
value
)
return
s
def
do_convert
(
ifp
,
ofp
,
knownempties
,
xml
=
0
):
attrs
=
{}
lastopened
=
None
knownempty
=
0
lastempty
=
0
while
1
:
line
=
ifp
.
readline
()
if
not
line
:
break
type
=
line
[
0
]
data
=
line
[
1
:]
if
data
and
data
[
-
1
]
==
"
\
n
"
:
data
=
data
[:
-
1
]
if
type
==
"-"
:
data
=
decode
(
data
)
ofp
.
write
(
data
)
if
"
\
n
"
in
data
:
lastopened
=
None
knownempty
=
0
lastempty
=
0
elif
type
==
"("
:
if
knownempty
and
xml
:
ofp
.
write
(
"<%s%s/>"
%
(
data
,
format_attrs
(
attrs
)))
else
:
ofp
.
write
(
"<%s%s>"
%
(
data
,
format_attrs
(
attrs
)))
if
knownempty
and
data
not
in
knownempties
:
# accumulate knowledge!
knownempties
.
append
(
data
)
attrs
=
{}
lastopened
=
data
lastempty
=
knownempty
knownempty
=
0
elif
type
==
")"
:
if
xml
:
if
not
lastempty
:
ofp
.
write
(
"</%s>"
%
data
)
elif
data
not
in
knownempties
:
if
lastopened
==
data
:
ofp
.
write
(
"</>"
)
else
:
ofp
.
write
(
"</%s>"
%
data
)
lastopened
=
None
lastempty
=
0
elif
type
==
"A"
:
name
,
type
,
value
=
string
.
split
(
data
,
" "
,
2
)
attrs
[
name
]
=
decode
(
value
)
elif
type
==
"e"
:
knownempty
=
1
def
sgml_convert
(
ifp
,
ofp
,
knownempties
=
()):
return
do_convert
(
ifp
,
ofp
,
list
(
knownempties
),
xml
=
0
)
def
xml_convert
(
ifp
,
ofp
,
knownempties
=
()):
return
do_convert
(
ifp
,
ofp
,
list
(
knownempties
),
xml
=
1
)
def
main
():
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
:
ifp
=
sys
.
stdin
ofp
=
sys
.
stdout
elif
len
(
sys
.
argv
)
==
2
:
ifp
=
open
(
sys
.
argv
[
1
])
ofp
=
sys
.
stdout
elif
len
(
sys
.
argv
)
==
3
:
ifp
=
open
(
sys
.
argv
[
1
])
ofp
=
open
(
sys
.
argv
[
2
],
"w"
)
else
:
usage
()
sys
.
exit
(
2
)
# knownempties is ignored in the XML version
try
:
convert
(
ifp
,
ofp
)
except
IOError
,
(
err
,
msg
):
if
err
!=
errno
.
EPIPE
:
raise
if
__name__
==
"__main__"
:
main
()
Doc/tools/latex2esis.py
deleted
100755 → 0
View file @
bbd7509d
This diff is collapsed.
Click to expand it.
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