Schematics deserializer override

        :return: ToOne instance
169023
def to_native(self, value, context=None):
        

        if isinstance(value, ToOne):
            return value

        value = self._cast_rid(value)
        return ToOne(self.rtype, self.field, rid=value)
1014850
def get_serializer(serializer_format):
    
    if serializer_format == Format.JSON:
        return _serialize_json
    if serializer_format == Format.PICKLE:
        return _serialize_pickle
1197280
def deserialize(self,
                    node: SchemaNode,
                    cstruct: Union[str, ColanderNullType]) \
            -> Optional[Pendulum]:
        
        if not cstruct:
            return colander.null
        try:
            result = coerce_to_pendulum(cstruct,
                                        assume_local=self.use_local_tz)
        except (ValueError, ParserError) as e:
            raise Invalid(node, "Invalid date/time: value={!r}, error="
                                "{!r}".format(cstruct, e))
        return result
313079
def get_serializer(self, instance=None, data=None,
                       many=False, partial=False):
        
        serializers = {
            'node': NodeRequestListSerializer,
            'vote': VoteRequestListSerializer,
            'comment': CommentRequestListSerializer,
            'rate': RatingRequestListSerializer,
        }
        context = self.get_serializer_context()
        service_code = context['request'].query_params.get('service_code', 'node')

        if service_code not in serializers.keys():
            serializer_class = self.get_serializer_class()
        else:
            serializer_class = serializers[service_code]

        return serializer_class(instance, many=many, partial=partial, context=context)
355480
def schemaNewDocParserCtxt(self):
        
        ret = libxml2mod.xmlSchemaNewDocParserCtxt(self._o)
        if ret is None:raise parserError('xmlSchemaNewDocParserCtxt() failed')
        __tmp = SchemaParserCtxt(_obj=ret)
        return __tmp
93833
def schema_from_context(context):
    """"""
    item_class = context.get('class')
    return (
        serializer_mapping[item_class] if item_class else BaseSchema,
        context.get('many', False)
    )
1100479
def _read_and_deserialize_dataone_type(self, response):
        
        try:
            return d1_common.xml.deserialize(response.content)
        except ValueError as e:
            self._raise_service_failure_invalid_dataone_type(response, e)
731691
def _deserialize_dict_attributes(cls, cls_context, dict_):
        

        dict_deserialized = {}

        for key in dict_.keys():
            key_deserialized = cls._deserialize_key(key)
            value_specs = cls._get_value_specs(cls_context, key_deserialized)

            if value_specs is not None:
                dict_deserialized[value_specs.name] = cls._deserialize_value(
                    value_specs.types,
                    dict_[key]
                )
            else:
                cls._warn_key_unknown(cls_context, key)

        return dict_deserialized
1232860
def schema_helper(self, name, _, schema=None, **kwargs):
        
        if schema is None:
            return None

        schema_instance = resolve_schema_instance(schema)

        schema_key = make_schema_key(schema_instance)
        self.warn_if_schema_already_in_spec(schema_key)
        self.openapi.refs[schema_key] = name

        json_schema = self.openapi.schema2jsonschema(schema_instance)

        return json_schema
1032479
def Deserialize(self, reader):
        
        self.AssetId = reader.ReadUInt256()
        self.Value = reader.ReadFixed8()
        self.ScriptHash = reader.ReadUInt160()
        if self.ScriptHash is None:
            raise Exception("Script hash is required from deserialize!!!!!!!!")
210625
def prep_for_deserialize(model, record, using, init_list=None):  # pylint:disable=unused-argument
    
    # TODO the parameter 'using' is not currently important.
    attribs = record.pop('attributes')  # NOQA pylint:disable=unused-variable

    mod = model.__module__.split('.')
    if hasattr(model._meta, 'app_label'):
        app_label = getattr(model._meta, 'app_label')
    elif mod[-1] == 'models':
        app_label = mod[-2]
    else:
        raise ImproperlyConfigured("Can't discover the app_label for %s, you must specify it via model meta options.")

    if len(record.keys()) == 1 and model._meta.db_table in record:
        # this is for objects with ManyToManyField and OneToOneField
        while len(record) == 1:
            record = list(record.values())[0]
            if record is None:
                return None

    fields = prep_for_deserialize_inner(model, record, init_list=init_list)

    if init_list and set(init_list).difference(fields).difference([SF_PK]):
        raise DatabaseError("Not found some expected fields")

    return dict(
        model='.'.join([app_label, model.__name__]),
        pk=record.pop('Id'),
        fields=fields,
    )
896398
def load_model_class(repo, content_type):
    
    schema = get_schema(repo, content_type).to_json()
    return deserialize(schema, module_name=schema['namespace'])
382562
def model_to_dict(instance, fields=None, exclude=None):
    

    return {
        field.name: field_to_dict(field, instance)
        for field in chain(instance._meta.concrete_fields, instance._meta.many_to_many)  # pylint: disable=W0212
        if not should_exclude_field(field, fields, exclude)
    }
1321610
def load_schema(schema_path):
    
    with open(schema_path, 'r') as schema_file:
        schema = simplejson.load(schema_file)
    resolver = RefResolver('', '', schema.get('models', {}))
    return build_request_to_validator_map(schema, resolver)
1225704
def to_json(self, extras=None):
        
        extras = extras or {}
        to_dict = model_to_dict(self)
        to_dict.update(extras)
        return json.dumps(to_dict, cls=sel.serializers.JsonEncoder)
936288
def from_dict(cls: typing.Type[T], dikt) -> T:
        """"""
        return util.deserialize_model(dikt, cls)
1022695
def deserialize(self):
        

        body = super(Deserializer, self).deserialize()

        self.parse(body)
        return self.normalize(body)