File tree 2 files changed +21
-1
lines changed
2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -142,6 +142,12 @@ Currently supported field types are:
142
142
given list of `-` seperated words, the words are optional defaulting to
143
143
`text1` `text2` and `text3`, min and max are optional, defaulting to `1`
144
144
and `1`
145
+ - `arr:[array_length_expression]:[single_element_format]` an array of entries
146
+ with format specified by `single_element_format`. `array_length_expression`
147
+ can be either a single number, or pair of numbers separated by `-` (i.e. 3-7),
148
+ defining range of lengths from with random length will be picked for each array
149
+ (Example `int_array:arr:1-5:int:1:250`)
150
+
145
151
146
152
## Todo
147
153
Original file line number Diff line number Diff line change @@ -92,7 +92,21 @@ def get_data_for_format(format):
92
92
93
93
return_val = ''
94
94
95
- if field_type == "bool" :
95
+ if field_type == 'arr' :
96
+ return_val = []
97
+ array_len_expr = split_f [2 ]
98
+ if '-' in array_len_expr :
99
+ (min ,max ) = array_len_expr .split ('-' )
100
+ array_len = generate_count (int (min ), int (max ))
101
+ else :
102
+ array_len = int (array_len_expr )
103
+
104
+ single_elem_format = field_name + ':' + format [len (field_name ) + len (field_type ) + len (array_len_expr ) + 3 : ]
105
+ for i in range (array_len ):
106
+ x = get_data_for_format (single_elem_format )
107
+ return_val .append (x [1 ])
108
+
109
+ elif field_type == "bool" :
96
110
return_val = random .choice ([True , False ])
97
111
98
112
elif field_type == "str" :
You can’t perform that action at this time.
0 commit comments