If metadata provided, use it to scramble the value based on data type
545110
def scramble_itemdata(self, oid, value):
        """"""
        if self.metadata is not None:
            path = ".//{0}[@{1}='{2}']".format(E_ODM.ITEM_DEF.value, A_ODM.OID.value, oid)
            elem = self.metadata.find(path)
            # for elem in self.metadata.iter(E_ODM.ITEM_DEF.value):
            datatype = elem.get(A_ODM.DATATYPE.value)

            codelist = None
            for el in elem.iter(E_ODM.CODELIST_REF.value):
                codelist = el.get(A_ODM.CODELIST_OID.value)

            length = 1 if not A_ODM.LENGTH in elem else int(elem.get(A_ODM.LENGTH.value))

            if A_ODM.SIGNIFICANT_DIGITS.value in elem.keys():
                sd = elem.get(A_ODM.SIGNIFICANT_DIGITS.value)
            else:
                sd = 0

            if A_ODM.DATETIME_FORMAT.value in elem.keys():
                dt_format = elem.get(A_ODM.DATETIME_FORMAT.value)
                for fmt in [('yyyy', '%Y'), ('MMM', '%b'), ('dd', '%d'), ('HH', '%H'), ('nn', '%M'), ('ss', '%S'),
                            ('-', '')]:
                    dt_format = dt_format.replace(fmt[0], fmt[1])

            if codelist is not None:
                return self.scramble_codelist(codelist)

            elif datatype == 'integer':
                return self.scramble_int(length)

            elif datatype == 'float':
                return self.scramble_float(length, sd)

            elif datatype in ['string', 'text']:
                return self.scramble_string(length)

            elif datatype in ['date', 'datetime']:
                return self.scramble_date(value, dt_format)

            elif datatype in ['time']:
                return self.scramble_time(dt_format)

            else:
                return self.scramble_value(value)

        else:
            return self.scramble_value(value)
300529
private short getDataType(String value)
    {
        short ret = STRING_TYPE;

        if(value.equals("number"))
            ret = NUMBER_TYPE;
        else if(value.equals("integer"))
            ret = INTEGER_TYPE;
        else if(value.equals("decimal"))
            ret = DECIMAL_TYPE;
        else if(value.equals("seconds"))
            ret = SECONDS_TYPE;
        else if(value.equals("datetime"))
            ret = DATETIME_TYPE;
        else if(value.equals("boolean"))
            ret = BOOLEAN_TYPE;

        return ret;
    }
496338
def parse_md_code_options(options):
    """"""

    metadata = []
    while options:
        name_and_value = re.split(r'[\s=]+', options, maxsplit=1)
        name = name_and_value[0]

        # Equal sign in between name and what's next?
        if len(name_and_value) == 2:
            sep = options[len(name):-len(name_and_value[1])]
            has_value = sep.find('=') >= 0
            options = name_and_value[1]
        else:
            has_value = False
            options = ''

        if not has_value:
            metadata.append((name, None))
            continue

        try:
            value = loads(options)
            options = ''
        except JSONDecodeError as err:
            try:
                split = err.colno - 1
            except AttributeError:
                # str(err) is like: "ValueError: Extra data: line 1 column 7 - line 1 column 50 (char 6 - 49)"
                match = re.match(r'.*char ([0-9]*)', str(err))
                split = int(match.groups()[0])

            value = loads(options[:split])
            options = options[split:]

        metadata.append((name, value))

    return metadata
963731
def parse_value(self, sn: "DataNode") -> ScalarValue:
        """"""
        res = sn.type.parse_value(self.value)
        if res is None:
            raise InvalidKeyValue(self.value)
        return res
425593
def make_val(clas,*vals):
    ""
    if clas.VALUE is None: raise TypeError('null meta-information in class for VALUE')
    clas.type_check(zip(*clas.VALUE)[1],vals,'VALUE')
    return msgpack.dumps(vals)
1010314
def _determine_keys(dictionary):
    """"""
    optional = {}
    defaults = {}
    mandatory = {}
    types = {}
    for key, value in dictionary.items():
        if isinstance(key, Optional):
            optional[key.value] = parse_schema(value)
            if isinstance(value, BaseSchema) and\
                    value.default is not UNSPECIFIED:
                defaults[key.value] = (value.default, value.null_values)
            continue  # pragma: nocover

        if type(key) is type:
            types[key] = parse_schema(value)
            continue

        mandatory[key] = parse_schema(value)
    return mandatory, optional, types, defaults
744720
def determine_metadata(self, request, view):
        """"""
        metadata = super(
            DynamicMetadata,
            self).determine_metadata(
            request,
            view)
        metadata['features'] = getattr(view, 'features', [])
        if hasattr(view, 'get_serializer'):
            serializer = view.get_serializer(dynamic=False)
            if hasattr(serializer, 'get_name'):
                metadata['resource_name'] = serializer.get_name()
            if hasattr(serializer, 'get_plural_name'):
                metadata['resource_name_plural'] = serializer.get_plural_name()
        metadata['properties'] = self.get_serializer_info(serializer)
        return metadata
506134
def _handle_load_unknown(self, data, original):
        """"""
        for key, val in original.items():
            if key not in self.fields:
                data[key] = val
        return data
164655
def _coerce_type(self, field_type, value):
        
        if value is None:
            return None
        if field_type == 'string':
            return str(value)
        elif field_type == 'text':
            return str(value)
        elif field_type == 'int':
            try:
                v = int(value)
                return str(v)
            except:
                return None
        elif field_type == 'float':
            try:
                v = float(value)
                return str(v)
            except:
                return None
        elif field_type == 'date':
            try:
                v = datetime.datetime(
                    value['year'],
                    value['month'],
                    value['day'],
                    value['hour'],
                    value['minute'],
                    value['second'],
                )
                v = v.strftime('%Y-%m-%dT%H:%M:%S.0Z')
                return v
            except:
                return None
        return str(value)
26303
def check(self, topic, value):
        
        datatype_key = topic.meta.get('datatype', 'none')
        self._datatypes[datatype_key].check(topic, value)
        validate_dt = topic.meta.get('validate', None)
        if validate_dt:
            self._datatypes[validate_dt].check(topic, value)
1248576
def data_key(data) :
    ""
    if isinstance(data, (bytes, float, frozenset, int, str, tuple)) :
        result = data
    else :
        # data itself is non-hashable
        result = id(data)
    #end if
    return \
        result
503350
function processValue(schema, value) {
  // "enum" is a reserved word, so only "type" and "items" can be destructured
  const { type, items } = schema;
  if (value === "") {
    return undefined;
  } else if (type === "array" && items && nums.has(items.type)) {
    return value.map(asNumber);
  } else if (type === "boolean") {
    return value === "true";
  } else if (type === "number") {
    return asNumber(value);
  }

  // If type is undefined, but an enum is present, try and infer the type from
  // the enum values
  if (schema.enum) {
    if (schema.enum.every(x => guessType(x) === "number")) {
      return asNumber(value);
    } else if (schema.enum.every(x => guessType(x) === "boolean")) {
      return value === "true";
    }
  }

  return value;
}
1331060
def extract_value(self, data):
        """"""
        errors = []
        if 'id' not in data:
            errors.append('Must have an `id` field')
        if 'type' not in data:
            errors.append('Must have a `type` field')
        elif data['type'] != self.type_:
            errors.append('Invalid `type` specified')

        if errors:
            raise ValidationError(errors)

        # If ``attributes`` is set, we've folded included data into this
        # relationship. Unserialize it if we have a schema set; otherwise we
        # fall back below to old behaviour of only IDs.
        if 'attributes' in data and self.__schema:
            result = self.schema.load({'data': data, 'included': self.root.included_data})
            return result.data if _MARSHMALLOW_VERSION_INFO[0] < 3 else result

        id_value = data.get('id')

        if self.__schema:
            id_value = self.schema.fields['id'].deserialize(id_value)

        return id_value
508165
def decode_datavalue(self,
                         datatype: str,
                         datavalue: Mapping[str, object]) -> object:
        
        decode = cast(Callable[[Client, str, Mapping[str, object]], object],
                      self.datavalue_decoder)
        return decode(self, datatype, datavalue)
373989
function(fields, data) {
    if (!_.isString(fields)) {
      return data;
    }

    // If a field is specified as `foo.bar` or `foo.bar.baz`,
    // Convert it to just `foo`
    var map = {};
    _.forEach(fields.split(','), function(field) {
      map[field.split('.')[0]] = 1;
    });

    var keys = _.keys(map);
    if (_.isArray(data)) {
      data = _.map(data, function(object) {
        return _.pick(object, keys);
      });
    } else if (_.isObject(data)) {
      data = _.pick(data, keys);
    }

    return data;
  }
436841
def _convert_type(self, data_type):
        '''
        
        '''
        if (data_type == 1) or (data_type == 41):
            dt_string = 'b'
        elif data_type == 2:
            dt_string = 'h'
        elif data_type == 4:
            dt_string = 'i'
        elif (data_type == 8) or (data_type == 33):
            dt_string = 'q'
        elif data_type == 11:
            dt_string = 'B'
        elif data_type == 12:
            dt_string = 'H'
        elif data_type == 14:
            dt_string = 'I'
        elif (data_type == 21) or (data_type == 44):
            dt_string = 'f'
        elif (data_type == 22) or (data_type == 45) or (data_type == 31):
            dt_string = 'd'
        elif (data_type == 32):
            dt_string = 'd'
        elif (data_type == 51) or (data_type == 52):
            dt_string = 's'
        return dt_string
125303
def _normalize_data_types(self, strategy):
        '''  '''
        for k, v in strategy.iteritems():
            if not isinstance(v, str):
                # There is probably nothing to do
                continue
            if v == 'true':
                strategy[k] = True
            elif v == 'false' or v is None:
                strategy[k] = False
            else:
                try:
                    if v.find('.') > 0:
                        strategy[k] = float(v)
                    else:
                        strategy[k] = int(v)
                except ValueError:
                    pass