|
Peach ::
Generators ::
dictionary ::
GeneratorList ::
Class GeneratorList
|
|
Class GeneratorList
source code
Iterates through a specified list of generators. When the end of the
list is reached a generator.GeneratorCompleted exceoption is raised.
NOTE: Generators are incremented by this object so DON'T SET A GROUP
ON THEM!
NOTE: We only increment to next generator in list when the
GeneratorCompleted exception has been thrown from current generator.
This allows one todo kewl things like have 2 static generators, then a
dictionary, then a repeater.
Example:
>>> gen = GeneratorList(None, [
... Static('1'),
... Static('2'),
... Static('3')
... ])
>>> print gen.getValue()
1
>>> gen.next()
>>> print gen.getValue()
2
>>> gen.next()
>>> print gen.getValue()
3
>>> try:
... gen.next()
... except:
... pass
>>> print gen.getValue()
3
Example:
>>> gen = GeneratorList(None, [
... Repeater(None, Static('Peach'), 1, 2),
... Static('Hello World')
... ])
>>> print gen.getValue()
Peach
>>> gen.next()
>>> print gen.getValue()
PeachPeach
>>> gen.next()
>>> print gen.getValue()
Hello World
>>> try:
... gen.next()
... except:
... pass
>>> print gen.getValue()
Hello World
Bad Example, group set on Generator in list:
>>> group = Group()
>>> gen = GeneratorList(group, [
... Repeater(group, Static('Peach'), 1, 2),
... Static('Hello World')
... ])
>>> print gen.getValue()
Peach
>>> group.next()
>>> print gen.getValue()
Hello World
>>> try:
... gen.next()
... except:
... pass
>>> print gen.getValue()
Hello World
__init__(self,
group,
list,
name=None)
(Constructor)
| source code
|
Base constructor, please call me!
- Parameters:
group (Group) - Group this Generator belongs to
list (list) - List of Generators to iterate through
name (string)
- Overrides:
generator.Generator.__init__
|
|
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.Generator.next
- (inherited documentation)
|
|
Return raw value w/o passing through transformer if set. OVERRIDE
- Returns: string
- Data before transformations
- Overrides:
generator.Generator.getRawValue
- (inherited documentation)
|
|
Get list of Generators.
- Returns: list
- list of Generators
|
|
Set list of Generators.
- Parameters:
list (list) - List of Generators
|