Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Private Attributes
xml.etree.ElementTree._IterParseIterator Class Reference

List of all members.

Public Member Functions

def __init__
def __next__
def __iter__

Public Attributes

 root

Private Attributes

 _file
 _close_file
 _events
 _index
 _root
 _parser

Detailed Description

Definition at line 1246 of file ElementTree.py.


Constructor & Destructor Documentation

def xml.etree.ElementTree._IterParseIterator.__init__ (   self,
  source,
  events,
  parser,
  close_source = False 
)

Definition at line 1248 of file ElementTree.py.

01248 
01249     def __init__(self, source, events, parser, close_source=False):
01250         self._file = source
01251         self._close_file = close_source
01252         self._events = []
01253         self._index = 0
01254         self.root = self._root = None
01255         self._parser = parser
01256         # wire up the parser for event reporting
01257         parser = self._parser._parser
01258         append = self._events.append
01259         if events is None:
01260             events = ["end"]
01261         for event in events:
01262             if event == "start":
01263                 try:
01264                     parser.ordered_attributes = 1
01265                     parser.specified_attributes = 1
01266                     def handler(tag, attrib_in, event=event, append=append,
01267                                 start=self._parser._start_list):
01268                         append((event, start(tag, attrib_in)))
01269                     parser.StartElementHandler = handler
01270                 except AttributeError:
01271                     def handler(tag, attrib_in, event=event, append=append,
01272                                 start=self._parser._start):
01273                         append((event, start(tag, attrib_in)))
01274                     parser.StartElementHandler = handler
01275             elif event == "end":
01276                 def handler(tag, event=event, append=append,
01277                             end=self._parser._end):
01278                     append((event, end(tag)))
01279                 parser.EndElementHandler = handler
01280             elif event == "start-ns":
01281                 def handler(prefix, uri, event=event, append=append):
01282                     append((event, (prefix or "", uri or "")))
01283                 parser.StartNamespaceDeclHandler = handler
01284             elif event == "end-ns":
01285                 def handler(prefix, event=event, append=append):
01286                     append((event, None))
01287                 parser.EndNamespaceDeclHandler = handler
01288             else:
01289                 raise ValueError("unknown event %r" % event)

Here is the caller graph for this function:


Member Function Documentation

Definition at line 1313 of file ElementTree.py.

01313 
01314     def __iter__(self):
01315         return self

Definition at line 1290 of file ElementTree.py.

01290 
01291     def __next__(self):
01292         while 1:
01293             try:
01294                 item = self._events[self._index]
01295             except IndexError:
01296                 if self._parser is None:
01297                     self.root = self._root
01298                     if self._close_file:
01299                         self._file.close()
01300                     raise StopIteration
01301                 # load event buffer
01302                 del self._events[:]
01303                 self._index = 0
01304                 data = self._file.read(16384)
01305                 if data:
01306                     self._parser.feed(data)
01307                 else:
01308                     self._root = self._parser.close()
01309                     self._parser = None
01310             else:
01311                 self._index = self._index + 1
01312                 return item


Member Data Documentation

Definition at line 1250 of file ElementTree.py.

Definition at line 1251 of file ElementTree.py.

Definition at line 1249 of file ElementTree.py.

Definition at line 1252 of file ElementTree.py.

Definition at line 1254 of file ElementTree.py.

Definition at line 1253 of file ElementTree.py.

Definition at line 1253 of file ElementTree.py.


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