def _build_parsed_values(self): """ @throws SampleException If there is a problem with sample creation """ if self._parameters is None or self._streams is None: self._load_streams() if self.raw_data not in self._streams: raise SampleException('Unknown stream %r' % self.raw_data) self._data_particle_type = self.raw_data parameters = self._streams.get(self.raw_data, []) values = [] for param in parameters: if param in self._ignore: continue p = self._parameters.get(param) if p.parameter_type == 'function': continue log.trace('Generating random data for param: %s name: %s', param, p.name) val = None if p.value_encoding in ['str', 'string']: val = self.random_string(20) elif p.value_encoding == 'int8': val = random.choice(self.INT8_RANDOM) elif p.value_encoding == 'int16': val = random.choice(self.INT16_RANDOM) elif p.value_encoding == 'int32': val = random.choice(self.INT32_RANDOM) elif p.value_encoding == 'int64': val = random.choice(self.INT64_RANDOM) elif p.value_encoding == 'uint8': val = random.choice(self.UINT8_RANDOM) elif p.value_encoding == 'uint16': val = random.choice(self.UINT16_RANDOM) elif p.value_encoding == 'uint32': val = random.choice(self.UINT32_RANDOM) elif p.value_encoding == 'uint64': val = random.choice(self.UINT64_RANDOM) elif p.value_encoding in ['float32', 'float64']: val = random.choice(self.FLOAT_RANDOM) else: log.debug('Unhandled parameter value encoding: %s', p) if val is not None: if 'array' in p.parameter_type and p.value_encoding not in [ 'str', 'string' ]: val = [val] * 2 values.append({'value_id': p.name, 'value': val}) return values
def _build_parsed_values(self): """ @throws SampleException If there is a problem with sample creation """ if self._parameters is None or self._streams is None: self._load_streams() if self.raw_data not in self._streams: raise SampleException("Unknown stream %r" % self.raw_data) self._data_particle_type = self.raw_data parameters = self._streams.get(self.raw_data, []) values = [] for param in parameters: if param in self._ignore: continue p = self._parameters.get(param) if p.parameter_type == "function": continue log.trace("Generating random data for param: %s name: %s", param, p.name) val = None if p.value_encoding in ["str", "string"]: val = self.random_string(20) elif p.value_encoding == "int8": val = random.choice(self.INT8_RANDOM) elif p.value_encoding == "int16": val = random.choice(self.INT16_RANDOM) elif p.value_encoding == "int32": val = random.choice(self.INT32_RANDOM) elif p.value_encoding == "int64": val = random.choice(self.INT64_RANDOM) elif p.value_encoding == "uint8": val = random.choice(self.UINT8_RANDOM) elif p.value_encoding == "uint16": val = random.choice(self.UINT16_RANDOM) elif p.value_encoding == "uint32": val = random.choice(self.UINT32_RANDOM) elif p.value_encoding == "uint64": val = random.choice(self.UINT64_RANDOM) elif p.value_encoding in ["float32", "float64"]: val = random.choice(self.FLOAT_RANDOM) else: log.debug("Unhandled parameter value encoding: %s", p) if val is not None: if "array" in p.parameter_type and p.value_encoding not in ["str", "string"]: val = [val] * 2 values.append({"value_id": p.name, "value": val}) return values
def my_sieve(raw_data): return_list = [] log.debug('SIEVE: pattern=%r, raw_data_len=%d', matcher.pattern, len(raw_data)) # do not descend into this loop unless we are at log level trace... if log.isEnabledFor('trace'): temp = raw_data[:] while temp: log.trace('SIEVE: raw_data: %s', temp[:32].encode('hex')) if len(temp) > 32: temp = temp[32:] else: temp = '' for match in matcher.finditer(raw_data): # if sentinel value present in this slice it is invalid if not SCAN_START_SENTINEL in raw_data[match.start():match.end()]: return_list.append((match.start(), match.end())) return return_list