Package gavo :: Package grammars :: Module common :: Class RowIterator
[frames] | no frames]

Class RowIterator

source code

object --+
         |
        RowIterator
Known Subclasses:

An object that encapsulates the a source being parsed by a grammar.

RowIterators are returned by Grammars' parse methods. Iterate over them to retrieve the rows contained in the source.

You can also call getParameters on them to retrieve document-global values (e.g., the parameters of a VOTable, a global header of a FITS table).

The getLocator method should return some string that aids the user in finding out why something went wrong (file name, line number, etc.)

This default implementation works for when source is a sequence of dictionaries. You will, in general, want to override _iteRows and getLocator, plus probably __init__ (to prepare external resources) and getParameters (if you have them; make sure to update any parameters you have with self.sourceRow as shown in the default getParameters implementation).

RowIterators are supposed to be self-destructing, i.e., they should release any external resources they hold when _iterRows runs out of items.

_iterRows should arrange for the instance variable recNo to be incremented by one for each item returned.

Instance Methods
 
__init__(self, grammar, sourceToken, sourceRow=None)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
__iter__(self) source code
 
getLocator(self) source code
 
getParameters(self) source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables
  notify = True
Properties
  recordNumber

Inherited from object: __class__

Method Details

__init__(self, grammar, sourceToken, sourceRow=None)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

Property Details

recordNumber

Get Method:
unreachable.recordNumber(self)