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
7fd173bf
Commit
7fd173bf
authored
Nov 30, 2001
by
Fred Drake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Synchronize with pulldom from PyXML (revision 1.18).
parent
49a5d03a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
2 deletions
+24
-2
Lib/xml/dom/pulldom.py
Lib/xml/dom/pulldom.py
+24
-2
No files found.
Lib/xml/dom/pulldom.py
View file @
7fd173bf
...
...
@@ -48,7 +48,7 @@ class PullDOM(xml.sax.ContentHandler):
self
.
_xmlns_attrs
=
[]
self
.
_xmlns_attrs
.
append
((
prefix
or
'xmlns'
,
uri
))
self
.
_ns_contexts
.
append
(
self
.
_current_context
.
copy
())
self
.
_current_context
[
uri
]
=
prefix
or
''
self
.
_current_context
[
uri
]
=
prefix
or
None
def
endPrefixMapping
(
self
,
prefix
):
self
.
_current_context
=
self
.
_ns_contexts
.
pop
()
...
...
@@ -211,6 +211,8 @@ class DOMEventStream:
self
.
stream
=
stream
self
.
parser
=
parser
self
.
bufsize
=
bufsize
if
not
hasattr
(
self
.
parser
,
'feed'
):
self
.
getEvent
=
self
.
_slurp
self
.
reset
()
def
reset
(
self
):
...
...
@@ -241,6 +243,8 @@ class DOMEventStream:
event
=
self
.
getEvent
()
def
getEvent
(
self
):
# use IncrementalParser interface, so we get the desired
# pull effect
if
not
self
.
pulldom
.
firstEvent
[
1
]:
self
.
pulldom
.
lastEvent
=
self
.
pulldom
.
firstEvent
while
not
self
.
pulldom
.
firstEvent
[
1
]:
...
...
@@ -253,8 +257,26 @@ class DOMEventStream:
self
.
pulldom
.
firstEvent
[
1
]
=
self
.
pulldom
.
firstEvent
[
1
][
1
]
return
rc
def
_slurp
(
self
):
""" Fallback replacement for getEvent() using the
standard SAX2 interface, which means we slurp the
SAX events into memory (no performance gain, but
we are compatible to all SAX parsers).
"""
self
.
parser
.
parse
(
self
.
stream
)
self
.
getEvent
=
self
.
_emit
return
self
.
_emit
()
def
_emit
(
self
):
""" Fallback replacement for getEvent() that emits
the events that _slurp() read previously.
"""
rc
=
self
.
pulldom
.
firstEvent
[
1
][
0
]
self
.
pulldom
.
firstEvent
[
1
]
=
self
.
pulldom
.
firstEvent
[
1
][
1
]
return
rc
def
clear
(
self
):
"
clear(): Explicitly release parsing objects
"
"
""clear(): Explicitly release parsing objects""
"
self
.
pulldom
.
clear
()
del
self
.
pulldom
self
.
parser
=
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