Peach :: generator :: SimpleGenerator :: Class SimpleGenerator
[hide private]

Class SimpleGenerator

source code



A simple generator contains another, possibly complex generator statement.
Usefull when breaking things apart for reuse.

To use, simply create a class that contains a _generator:

        class MySimpleGenerator(SimpleGenerator):
                def __init__(self, group = None):
                        SimpleGenerator.__init__(self, group)
                        self._generator = GeneratorList(None, [
                                Static('AAA'),
                                Repeater(None, Static('A'), 1, 100)
                                ])

NOTE: Do not set group on you generators unless they will not be incremented
by self._generator.next().

@see: L{Generator}

Instance Methods [hide private]
 
__init__(self, group=None)
Base constructor, please call me!
source code
 
next(self)
Next value.
source code
string
getRawValue(self)
Return raw value w/o passing through transformer if set.
source code
 
reset(self)
Called to reset the generator to its initial state.
source code

Inherited from Generator: __iter__, getGroup, getName, getTransformer, getValue, identity, setGroup, setName, setTransformer

Method Details [hide private]

__init__(self, group=None)
(Constructor)

source code 

Base constructor, please call me!

Parameters:
  • group (Group) - Group to use
Overrides: Generator.__init__

next(self)

source code 

Next value. OVERRIDE

From Python docs on next():

The intention of the protocol is that once an iterator's next() method raises StopIteration, it will continue to do so on subsequent calls. Implementations that do not obey this property are deemed broken. (This constraint was added in Python 2.3; in Python 2.2, various iterators are broken according to this rule.)

For Generators, please use the GeneratorCompleted exception instead of StopIteration (its a subclass).

Overrides: Generator.next
(inherited documentation)

getRawValue(self)

source code 

Return raw value w/o passing through transformer if set. OVERRIDE

Returns: string
Data before transformations
Overrides: Generator.getRawValue
(inherited documentation)

reset(self)

source code 

Called to reset the generator to its initial state. OVERRIDE

Overrides: Generator.reset
(inherited documentation)