1
2 '''
3 Incrementing generators (numerical, etc)
4
5 @author: Michael Eddington
6 @version: $Id: Peach.Generators.incrementor-pysrc.html 1138 2008-08-16 19:39:03Z meddingt $
7 '''
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37 import struct
38 from types import *
39 from Peach import generator, group
40 from Peach.generator import *
41
42
43
45 '''
46 Increment a value by another value each round. For example,
47 one could set 1 as an initial value with an incrementor of 1.
48 '''
49
50 _roundCount = 0
51 _value = None
52 _incrementor = None
53 _currentValue = None
54 _formatString = None
55 _maxValue = None
56 _maxIterations = None
57 _packString = None
58
59 - def __init__(self, group = None, value = 1, incrementor = 1, formatString = None,
60 maxValue = None, maxIterations = None, packString = None):
61 '''
62 @type group: Group
63 @param group: Group this generator works with
64 @type value: number
65 @param value: Number to increment
66 @type incrementor: number
67 @param incrementor: Increment amount (can be negative), default is 1
68 @type formatString: string
69 @param formatString: Format string for value (optional)
70 @type maxValue: number
71 @param maxValue: Maximum value (optional, default None)
72 @type maxIterations: number
73 @param maxIterations: Maximum number of times to increment
74 value (optional, default None)
75 @type packString: string
76 @param packString: Pack format string. Note that use of this
77 option will override formatString. (optional, default None)
78 '''
79 Generator.__init__(self)
80 self._value = value
81 self._incrementor = incrementor
82 self._formatString = formatString
83 self._maxValue = maxValue
84 self._maxIterations = maxIterations
85 self._packString = packString
86 self.setGroup(group)
87
102
106
128
130 '''
131 Set value to increment.
132
133 @type value: number
134 @param value: Number to increment
135 '''
136 self._value = value
137
165 unittest = staticmethod(unittest)
166
167
169 '''
170 Each call to getValue will increment. Usefull to make a string
171 unique accross fuzz.
172 '''
173
174 _incrementor = None
175
176 - def __init__(self, group = None, value = 1, incrementor = 1, formatString = None):
177 '''
178 @type group: Group
179 @param group: Group this generator works with
180 @type value: number
181 @param value: Number to increment
182 @type incrementor: number
183 @param incrementor: Amount to increment
184 @type formatString: string
185 @param formatString: Format string for value (optional)
186 '''
187 generator.Generator.__init__(self)
188 self._incrementor = Incrementor(group, value, incrementor, formatString)
189
192
195
200
202 '''
203 Set value to increment.
204
205 @type value: number
206 @param value: Number to increment
207 '''
208 self._incrementor.setValue(value)
209
221 unittest = staticmethod(unittest)
222
224 '''
225 Each round we increment. Has it's uses :)
226 '''
227
228 _incrementor = None
229
230 - def __init__(self, value = 1, incrementor = 1, formatString = None):
231 '''
232 @type value: number
233 @param value: Number to increment
234 @type incrementor: number
235 @param incrementor: Amount to increment
236 @type formatString: string
237 @param formatString: Format string for value (optional)
238 '''
239
240 self._incrementor = Incrementor(None, value, incrementor, formatString)
241
245
248
251
253 '''
254 Set value to increment.
255
256 @type value: number
257 @param value: Number to increment
258 '''
259 self._incrementor.setValue(value)
260
272 unittest = staticmethod(unittest)
273
274
275
276
277