Peach :: Generators :: dictionary :: GeneratorChoice :: Class GeneratorChoice
[hide private]

Class GeneratorChoice

source code



Will choose from a list of Generators.  See use cases below for
further description of operation:

Case 1 - minOccurs and maxOccurs are 1.  In this case a single
         generator is selected N times.
Case 2 - minOccurs is 1 and maxOccurs is 100.  In this case
         N sets of random items are chosen.
Case 3 - minOccurs is 0 and maxOccurs is 1.  You will always
         get 1 case were 0 items are chosen and 1 case of
     other items chosen

Currently N == 10.

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

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

Method Details [hide private]

__init__(self, group, minOccurs, maxOccurs, groups, list, n=10, name=None)
(Constructor)

source code 

Base constructor, please call me!

Parameters:
  • group (Group) - Group this Generator belongs to
  • list (list) - List of Generators to choose frome
  • name (string)
Overrides: generator.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.Generator.next
(inherited documentation)

reset(self)

source code 

Called to reset the generator to its initial state. OVERRIDE

Overrides: generator.Generator.reset
(inherited documentation)

getRawValue(self)

source code 

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

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