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
0f9bfd3d
Commit
0f9bfd3d
authored
Sep 28, 2001
by
Fred Drake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert most uses of the string module to string methods.
(string.join() lives!)
parent
bbf7a407
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
16 deletions
+15
-16
Doc/tools/sgmlconv/esis2sgml.py
Doc/tools/sgmlconv/esis2sgml.py
+9
-9
Doc/tools/sgmlconv/esistools.py
Doc/tools/sgmlconv/esistools.py
+1
-2
Doc/tools/sgmlconv/latex2esis.py
Doc/tools/sgmlconv/latex2esis.py
+5
-5
No files found.
Doc/tools/sgmlconv/esis2sgml.py
View file @
0f9bfd3d
...
...
@@ -97,7 +97,7 @@ def convert(ifp, ofp, xml=0, autoclose=(), verbatims=()):
data
=
esistools
.
decode
(
data
)
data
=
escape
(
data
)
if
not
inverbatim
:
data
=
string
.
replace
(
data
,
"---"
,
"—"
)
data
=
data
.
replace
(
"---"
,
"—"
)
ofp
.
write
(
data
)
if
"
\
n
"
in
data
:
lastopened
=
None
...
...
@@ -139,7 +139,7 @@ def convert(ifp, ofp, xml=0, autoclose=(), verbatims=()):
lastempty
=
0
inverbatim
=
0
elif
type
==
"A"
:
name
,
type
,
value
=
string
.
split
(
data
,
" "
,
2
)
name
,
type
,
value
=
data
.
split
(
" "
,
2
)
name
=
map_gi
(
name
,
_attr_map
)
attrs
[
name
]
=
esistools
.
decode
(
value
)
elif
type
==
"e"
:
...
...
@@ -165,7 +165,7 @@ def dump_empty_element_names(knownempties):
line
=
fp
.
readline
()
if
not
line
:
break
gi
=
string
.
strip
(
line
)
gi
=
line
.
strip
(
)
if
gi
:
d
[
gi
]
=
gi
fp
=
open
(
EMPTIES_FILENAME
,
"w"
)
...
...
@@ -177,9 +177,9 @@ def dump_empty_element_names(knownempties):
def
update_gi_map
(
map
,
names
,
fromsgml
=
1
):
for
name
in
string
.
split
(
names
,
","
):
for
name
in
names
.
split
(
","
):
if
fromsgml
:
uncased
=
string
.
lower
(
name
)
uncased
=
name
.
lower
(
)
else
:
uncased
=
name
map
[
uncased
]
=
name
...
...
@@ -211,7 +211,7 @@ def main():
elif
opt
in
(
"-x"
,
"--xml"
):
xml
=
1
elif
opt
in
(
"-a"
,
"--autoclose"
):
autoclose
=
string
.
split
(
arg
,
","
)
autoclose
=
arg
.
split
(
","
)
elif
opt
==
"--elements-map"
:
elem_names
=
(
"%s,%s"
%
(
elem_names
,
arg
))[
1
:]
elif
opt
==
"--attributes-map"
:
...
...
@@ -241,9 +241,9 @@ def main():
# stream but set up conversion tables to get the case right on output
global
_normalize_case
_normalize_case
=
string
.
lower
update_gi_map
(
_elem_map
,
string
.
split
(
elem_names
,
","
))
update_gi_map
(
_attr_map
,
string
.
split
(
attr_names
,
","
))
update_gi_map
(
_values_map
,
string
.
split
(
value_names
,
","
))
update_gi_map
(
_elem_map
,
elem_names
.
split
(
","
))
update_gi_map
(
_attr_map
,
attr_names
.
split
(
","
))
update_gi_map
(
_values_map
,
value_names
.
split
(
","
))
else
:
global
map_gi
map_gi
=
null_map_gi
...
...
Doc/tools/sgmlconv/esistools.py
View file @
0f9bfd3d
"""Miscellaneous utility functions useful for dealing with ESIS streams."""
import
re
import
string
import
xml.dom.pulldom
...
...
@@ -182,7 +181,7 @@ class ESISReader(xml.sax.xmlreader.XMLReader):
elif
token
==
'?'
:
if
handler
:
if
' '
in
data
:
target
,
data
=
string
.
split
(
data
,
None
,
1
)
target
,
data
=
data
.
split
(
None
,
1
)
else
:
target
,
data
=
data
,
""
handler
.
processingInstruction
(
target
,
decode
(
data
))
...
...
Doc/tools/sgmlconv/latex2esis.py
View file @
0f9bfd3d
...
...
@@ -109,7 +109,7 @@ class Conversion:
self
.
write
=
ofp
.
write
self
.
ofp
=
ofp
self
.
table
=
table
self
.
line
=
string
.
join
(
map
(
string
.
rstrip
,
ifp
.
readlines
())
,
"
\
n
"
)
self
.
line
=
string
.
join
(
[
s
.
rstrip
()
for
s
in
ifp
.
readlines
()]
,
"
\
n
"
)
self
.
preamble
=
1
def
convert
(
self
):
...
...
@@ -170,7 +170,7 @@ class Conversion:
entry = self.get_entry(macroname)
if entry.verbatim:
# magic case!
pos =
string.find(line,
"
\\
end
{
%
s
}
" % macroname)
pos =
line.find(
"
\\
end
{
%
s
}
" % macroname)
text = line[m.end(1):pos]
stack.append(entry.name)
self.write("
(
%
s
\
n
" % entry.outputname)
...
...
@@ -410,7 +410,7 @@ def convert(ifp, ofp, table):
def skip_white(line):
while line and line[0] in "
%
\
n
\
t
\
r":
line =
string.lstrip(line[1:]
)
line =
line[1:].lstrip(
)
return line
...
...
@@ -461,14 +461,14 @@ class TableParser(XMLParser):
self.__current.verbatim = attrs.get("
verbatim
") == "
yes
"
if attrs.has_key("
outputname
"):
self.__current.outputname = attrs.get("
outputname
")
self.__current.endcloses =
string.split(attrs.get("
endcloses
", "")
)
self.__current.endcloses =
attrs.get("
endcloses
", "").split(
)
def end_environment(self):
self.end_macro()
def start_macro(self, attrs):
name = attrs["
name
"]
self.__current = TableEntry(name)
self.__current.closes =
string.split(attrs.get("
closes
", "")
)
self.__current.closes =
attrs.get("
closes
", "").split(
)
if attrs.has_key("
outputname
"):
self.__current.outputname = attrs.get("
outputname
")
def end_macro(self):
...
...
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