Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
5cb2eb85
Commit
5cb2eb85
authored
Aug 24, 2005
by
Fred Drake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
there has only been one "right" way to import Expat for a long time now;
use it
parent
af422b0f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
34 deletions
+24
-34
lib/python/Shared/DC/xml/ppml.py
lib/python/Shared/DC/xml/ppml.py
+4
-4
lib/python/TAL/XMLParser.py
lib/python/TAL/XMLParser.py
+7
-9
lib/python/TAL/tests/utils.py
lib/python/TAL/tests/utils.py
+13
-21
No files found.
lib/python/Shared/DC/xml/ppml.py
View file @
5cb2eb85
...
...
@@ -750,7 +750,7 @@ def test1():
print
z
,
'
\
012
'
def
test2
():
import
xml.parsers.
py
expat
import
xml.parsers.expat
c
=
C
()
c
.
foo
=
1
c
.
bar
=
2
...
...
@@ -778,7 +778,7 @@ def test2():
file
=
''
F
=
xmlPickler
()
F
.
binary
=
0
p
=
xml
.
parsers
.
py
expat
.
ParserCreate
()
p
=
xml
.
parsers
.
expat
.
ParserCreate
()
p
.
CharacterDataHandler
=
F
.
handle_data
p
.
StartElementHandler
=
F
.
unknown_starttag
p
.
EndElementHandler
=
F
.
unknown_endtag
...
...
@@ -786,13 +786,13 @@ def test2():
print
r
,
'
\
012
'
def
test3
():
import
xml.parsers.
py
expat
import
xml.parsers.expat
data
=
open
(
'Data.xml'
).
read
()
file
=
open
(
'out'
,
'w'
+
'b'
)
F
=
xmlPickler
()
F
.
file
=
file
F
.
binary
=
1
p
=
xml
.
parsers
.
py
expat
.
ParserCreate
()
p
=
xml
.
parsers
.
expat
.
ParserCreate
()
p
.
CharacterDataHandler
=
F
.
handle_data
p
.
StartElementHandler
=
F
.
unknown_starttag
p
.
EndElementHandler
=
F
.
unknown_endtag
...
...
lib/python/TAL/XMLParser.py
View file @
5cb2eb85
...
...
@@ -15,8 +15,14 @@
Generic expat-based XML parser base class.
"""
import
xml.parsers.expat
import
zLOG
XMLParseError
=
xml
.
parsers
.
expat
.
ExpatError
class
XMLParser
:
ordered_attributes
=
0
...
...
@@ -63,15 +69,7 @@ class XMLParser:
"Can't set expat handler %s"
%
name
)
def
createParser
(
self
,
encoding
=
None
):
global
XMLParseError
try
:
from
Products.ParsedXML.Expat
import
pyexpat
XMLParseError
=
pyexpat
.
ExpatError
return
pyexpat
.
ParserCreate
(
encoding
,
' '
)
except
ImportError
:
from
xml.parsers
import
expat
XMLParseError
=
expat
.
ExpatError
return
expat
.
ParserCreate
(
encoding
,
' '
)
return
xml
.
parsers
.
expat
.
ParserCreate
(
encoding
,
' '
)
def
parseFile
(
self
,
filename
):
self
.
parseStream
(
open
(
filename
))
...
...
lib/python/TAL/tests/utils.py
View file @
5cb2eb85
...
...
@@ -10,36 +10,28 @@ if codedir not in sys.path:
sys
.
path
.
append
(
codedir
)
import
unittest
import
xml.parsers.expat
# Set skipxml to true if an XML parser could not be found.
pyexpat
=
None
skipxml
=
0
try
:
import
pyexpat
except
ImportError
:
try
:
# the C extension in PyXML
import
xml.parsers.pyexpat
except
ImportError
:
skipxml
=
1
else
:
pyexpat
=
xml
.
parsers
.
pyexpat
# (But Python always includes one now.)
skipxml
=
False
# Set oldexpat if the StartDoctypeDeclHandler and XmlDeclHandler are
# not supported. The tests need to know whether the events reported
# by those handlers should be expected, but need to make sure the
# right thing is returned if they are.
oldexpat
=
0
if
pyexpat
is
not
None
:
p
=
pyexpat
.
ParserCreate
()
# Can't use hasattr() since pyexpat supports the handler
# attributes in a broken way.
try
:
p
.
StartDoctypeDeclHandler
=
None
except
AttributeError
:
oldexpat
=
1
#
oldexpat
=
False
p
=
xml
.
parsers
.
expat
.
ParserCreate
()
#
# Can't use hasattr() since pyexpat supports the handler
# attributes in a broken way.
try
:
p
.
StartDoctypeDeclHandler
=
None
except
AttributeError
:
oldexpat
=
True
def
run_suite
(
suite
,
outf
=
None
,
errf
=
None
):
...
...
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