Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Private Member Functions
xml.dom.pulldom.DOMEventStream Class Reference

List of all members.

Public Member Functions

def __init__
def reset
def __getitem__
def __next__
def __iter__
def expandNode
def getEvent
def clear

Public Attributes

 stream
 parser
 bufsize
 getEvent
 pulldom

Private Member Functions

def _slurp
def _emit

Detailed Description

Definition at line 205 of file pulldom.py.


Constructor & Destructor Documentation

def xml.dom.pulldom.DOMEventStream.__init__ (   self,
  stream,
  parser,
  bufsize 
)

Definition at line 206 of file pulldom.py.

00206 
00207     def __init__(self, stream, parser, bufsize):
00208         self.stream = stream
00209         self.parser = parser
00210         self.bufsize = bufsize
00211         if not hasattr(self.parser, 'feed'):
00212             self.getEvent = self._slurp
00213         self.reset()

Here is the caller graph for this function:


Member Function Documentation

def xml.dom.pulldom.DOMEventStream.__getitem__ (   self,
  pos 
)

Definition at line 220 of file pulldom.py.

00220 
00221     def __getitem__(self, pos):
00222         rc = self.getEvent()
00223         if rc:
00224             return rc
00225         raise IndexError

Definition at line 232 of file pulldom.py.

00232 
00233     def __iter__(self):
00234         return self

Definition at line 226 of file pulldom.py.

00226 
00227     def __next__(self):
00228         rc = self.getEvent()
00229         if rc:
00230             return rc
00231         raise StopIteration

def xml.dom.pulldom.DOMEventStream._emit (   self) [private]
Fallback replacement for getEvent() that emits
    the events that _slurp() read previously.

Definition at line 275 of file pulldom.py.

00275 
00276     def _emit(self):
00277         """ Fallback replacement for getEvent() that emits
00278             the events that _slurp() read previously.
00279         """
00280         rc = self.pulldom.firstEvent[1][0]
00281         self.pulldom.firstEvent[1] = self.pulldom.firstEvent[1][1]
00282         return rc

Here is the caller graph for this function:

def xml.dom.pulldom.DOMEventStream._slurp (   self) [private]
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).

Definition at line 265 of file pulldom.py.

00265 
00266     def _slurp(self):
00267         """ Fallback replacement for getEvent() using the
00268             standard SAX2 interface, which means we slurp the
00269             SAX events into memory (no performance gain, but
00270             we are compatible to all SAX parsers).
00271         """
00272         self.parser.parse(self.stream)
00273         self.getEvent = self._emit
00274         return self._emit()

Here is the call graph for this function:

clear(): Explicitly release parsing objects

Definition at line 283 of file pulldom.py.

00283 
00284     def clear(self):
00285         """clear(): Explicitly release parsing objects"""
00286         self.pulldom.clear()
00287         del self.pulldom
00288         self.parser = None
00289         self.stream = None

def xml.dom.pulldom.DOMEventStream.expandNode (   self,
  node 
)

Definition at line 235 of file pulldom.py.

00235 
00236     def expandNode(self, node):
00237         event = self.getEvent()
00238         parents = [node]
00239         while event:
00240             token, cur_node = event
00241             if cur_node is node:
00242                 return
00243             if token != END_ELEMENT:
00244                 parents[-1].appendChild(cur_node)
00245             if token == START_ELEMENT:
00246                 parents.append(cur_node)
00247             elif token == END_ELEMENT:
00248                 del parents[-1]
00249             event = self.getEvent()

Definition at line 250 of file pulldom.py.

00250 
00251     def getEvent(self):
00252         # use IncrementalParser interface, so we get the desired
00253         # pull effect
00254         if not self.pulldom.firstEvent[1]:
00255             self.pulldom.lastEvent = self.pulldom.firstEvent
00256         while not self.pulldom.firstEvent[1]:
00257             buf = self.stream.read(self.bufsize)
00258             if not buf:
00259                 self.parser.close()
00260                 return None
00261             self.parser.feed(buf)
00262         rc = self.pulldom.firstEvent[1][0]
00263         self.pulldom.firstEvent[1] = self.pulldom.firstEvent[1][1]
00264         return rc

Definition at line 214 of file pulldom.py.

00214 
00215     def reset(self):
00216         self.pulldom = PullDOM()
00217         # This content handler relies on namespace support
00218         self.parser.setFeature(xml.sax.handler.feature_namespaces, 1)
00219         self.parser.setContentHandler(self.pulldom)

Here is the caller graph for this function:


Member Data Documentation

Definition at line 209 of file pulldom.py.

Definition at line 211 of file pulldom.py.

Definition at line 208 of file pulldom.py.

Definition at line 215 of file pulldom.py.

Definition at line 207 of file pulldom.py.


The documentation for this class was generated from the following file: