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

Class RowIterator

source code

        object --+        
                 |        
common.RowIterator --+    
                     |    
common.FileRowIterator --+
                         |
                        RowIterator

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
 
getLocator(self) source code

Inherited from common.FileRowIterator: __init__

Inherited from common.RowIterator: __iter__, getParameters

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

Class Variables
  chunkSize = 8192

Inherited from common.RowIterator: notify

Properties

Inherited from common.RowIterator: recordNumber

Inherited from object: __class__

Method Details

getLocator(self)

source code 
Overrides: common.RowIterator.getLocator