Return a CourseLocator parsing the given serialized string
        :param serialized: matches the string to a CourseLocator
359763
def _from_string(cls, serialized):
        
        parse = cls.parse_url(serialized)

        if parse['version_guid']:
            parse['version_guid'] = cls.as_object_id(parse['version_guid'])

        return cls(**{key: parse.get(key) for key in cls.KEY_FIELDS})
681696
def from_string(cls, string):
        
        cls.TYPE.setParseAction(cls.make)
        try:
            return cls.TYPE.parseString(string, parseAll=True)[0]
        except ParseException:
            log.error("Failed to parse '{0}'".format(string))
            raise
970823
public static <T extends PersistableTransfer> T deserializeFrom(
            String serialized) {
        if (serialized == null)
            return null;
        ByteArrayInputStream byteStream = new ByteArrayInputStream(
                serialized.getBytes(UTF8));
        try{
            return deserializeFrom(byteStream);
        }finally{
            try { byteStream.close(); } catch(IOException ioe) { } ;
        }
    }
1191389
def loads(astring):
        """"""
        try:
            return marshal.loads(zlib.decompress(astring))
        except zlib.error as e:
            raise SerializerError(
                'Cannot decompress object ("{}")'.format(str(e))
            )
        except Exception as e:
            # marshal module does not provide a proper Exception model
            raise SerializerError(
                'Cannot restore object ("{}")'.format(str(e))
            )
691512
def loads(content, dict_=dict):
    
    if not isinstance(content, basestring):
        raise ValueError('The first parameter needs to be a string object, ',
                         '%r is passed' % type(content))
    decoder = Decoder(content, dict_)
    decoder.parse()
    return decoder.data
406295
def get_serializer(serializer):
    
    if isinstance(serializer, string_types):
        try:
            app_label, serializer_name = serializer.split('.')
            app_package = get_application(app_label)
            serializer_module = import_module('%s.serializers' % app_package)
            serializer = getattr(serializer_module, serializer_name)
        except Exception as e:
            logger.error('Serializer %s not found: %s' % (serializer, e))
            return None
    return serializer
1224956
def parse(cls, on_str, force_type=None):  # @ReservedAssignment
        """"""

        on_str_orig = on_str

        if on_str is None:
            return None

        if not on_str:
            raise NotObjectNumberError("Got null input")

        if not isinstance(on_str, string_types):
            raise NotObjectNumberError("Must be a string. Got a {} ".format(type(on_str)))

        # if isinstance(on_str, unicode):
        #     dataset = on_str.encode('ascii')

        if force_type:
            type_ = force_type
        else:
            type_ = on_str[0]

        on_str = on_str[1:]

        if type_ not in list(cls.NDS_LENGTH.keys()):
            raise NotObjectNumberError("Unknown type character '{}' for '{}'".format(type_, on_str_orig))

        ds_length = len(on_str) - cls.NDS_LENGTH[type_]

        if ds_length not in cls.DATASET_LENGTHS:
            raise NotObjectNumberError(
                "Dataset string '{}' has an unfamiliar length: {}".format(on_str_orig, ds_length))

        ds_lengths = cls.DATASET_LENGTHS[ds_length]

        assignment_class = ds_lengths[2]

        try:
            dataset = int(ObjectNumber.base62_decode(on_str[0:ds_lengths[0]]))

            if ds_lengths[1]:
                i = len(on_str) - ds_lengths[1]
                revision = int(ObjectNumber.base62_decode(on_str[i:]))
                on_str = on_str[0:i]  # remove the revision
            else:
                revision = None

            on_str = on_str[ds_lengths[0]:]

            if type_ == cls.TYPE.DATASET:
                return DatasetNumber(dataset, revision=revision, assignment_class=assignment_class)

            elif type_ == cls.TYPE.TABLE:
                table = int(ObjectNumber.base62_decode(on_str))
                return TableNumber(
                    DatasetNumber(dataset, assignment_class=assignment_class), table, revision=revision)

            elif type_ == cls.TYPE.PARTITION:
                partition = int(ObjectNumber.base62_decode(on_str))
                return PartitionNumber(
                    DatasetNumber(dataset, assignment_class=assignment_class), partition, revision=revision)

            elif type_ == cls.TYPE.COLUMN:
                table = int(ObjectNumber.base62_decode(on_str[0:cls.DLEN.TABLE]))
                column = int(ObjectNumber.base62_decode(on_str[cls.DLEN.TABLE:]))

                return ColumnNumber(
                    TableNumber(DatasetNumber(dataset, assignment_class=assignment_class), table),
                    column, revision=revision)

            elif type_ == cls.TYPE.OTHER1 or type_ == cls.TYPE.CONFIG:
                    return GeneralNumber1(on_str_orig[0],
                                          DatasetNumber(dataset, assignment_class=assignment_class),
                                          int(ObjectNumber.base62_decode(on_str[0:cls.DLEN.OTHER1])),
                                          revision=revision)

            elif type_ == cls.TYPE.OTHER2:
                    return GeneralNumber2(on_str_orig[0],
                                          DatasetNumber(dataset, assignment_class=assignment_class),
                                          int(ObjectNumber.base62_decode(on_str[0:cls.DLEN.OTHER1])),
                                          int(ObjectNumber.base62_decode(
                                              on_str[cls.DLEN.OTHER1:cls.DLEN.OTHER1+cls.DLEN.OTHER2])),
                                          revision=revision)

            else:

                raise NotObjectNumberError('Unknown type character: ' + type_ + ' in ' + str(on_str_orig))

        except Base62DecodeError as e:
            raise NotObjectNumberError('Unknown character:  ' + str(e))
197161
def parse(celf, s) :
        ""

        def from_string_elts(celf, attrs, tree) :
            elts = dict((k, attrs[k]) for k in attrs)
            child_tags = dict \
              (
                (childclass.tag_name, childclass)
                for childclass in tuple(celf.tag_elts.values()) + (Introspection.Annotation,)
              )
            children = []
            for child in tree :
                if child.tag not in child_tags :
                    raise KeyError("unrecognized tag %s" % child.tag)
                #end if
                childclass = child_tags[child.tag]
                childattrs = {}
                for attrname in childclass.tag_attrs :
                    if hasattr(childclass, "tag_attrs_optional") and attrname in childclass.tag_attrs_optional :
                        childattrs[attrname] = child.attrib.get(attrname, None)
                    else :
                        if attrname not in child.attrib :
                            raise ValueError("missing %s attribute for %s tag" % (attrname, child.tag))
                        #end if
                        childattrs[attrname] = child.attrib[attrname]
                    #end if
                #end for
                if hasattr(childclass, "attr_convert") :
                    for attr in childclass.attr_convert :
                        if attr in childattrs :
                            childattrs[attr] = childclass.attr_convert[attr](childattrs[attr])
                        #end if
                    #end for
                #end if
                children.append(from_string_elts(childclass, childattrs, child))
            #end for
            for child_tag, childclass in tuple(celf.tag_elts.items()) + ((), (("annotations", Introspection.Annotation),))[tree.tag != "annotation"] :
                for child in children :
                    if isinstance(child, childclass) :
                        if child_tag not in elts :
                            elts[child_tag] = []
                        #end if
                        elts[child_tag].append(child)
                    #end if
                #end for
            #end for
            return \
                celf(**elts)
        #end from_string_elts

    #begin parse
        tree = XMLElementTree.fromstring(s)
        assert tree.tag == "node", "root of introspection tree must be <node> tag"
        return \
            from_string_elts(Introspection, {}, tree)
1180928
def from_string(cls, alg_str):
        
        try:
            return cls(int(alg_str[1]) - 1, ord(alg_str[0]) - 97)
        except ValueError as e:
            raise ValueError("Location.from_string {} invalid: {}".format(alg_str, e))
1153875
def parse(pem_str):
    # type: (bytes) -> List[AbstractPEMObject]
    
    return [
        _PEM_TO_CLASS[match.group(1)](match.group(0))
        for match in _PEM_RE.finditer(pem_str)
    ]
232012
def _get_deserializer(cls, cls_for):
        

        if cls_for.__name__ in cls._custom_deserializers:
            return cls._custom_deserializers[cls_for.__name__]

        return JsonAdapter
1033678
def from_string(cls, string, version):
        
        header, payload = string.split("\n",1)
        if payload[0] == '\n': # There's an extra
            payload = payload[1:]
        if int(version) == 1:
            arc_header_re = ARC1_HEADER_RE
        elif int(version) == 2:
            arc_header_re = ARC2_HEADER_RE

        matches = arc_header_re.search(header)
        headers = matches.groupdict()
        arc_header = ARCHeader(**headers)
        return cls(header = arc_header, payload = payload, version = version)
721825
def from_string(cls, s):
        

        log.debug("Parsing email from string")
        message = email.message_from_string(s)
        return cls(message)
337613
public static Bind parse(String serialized) {
        try {
            String[] parts = serialized.split(":");
            switch (parts.length) {
            case 2: {
                return new Bind(parts[0], new Volume(parts[1]));
            }
            case 3: {
                String[] flags = parts[2].split(",");
                AccessMode accessMode = AccessMode.DEFAULT;
                SELContext seMode = SELContext.DEFAULT;
                Boolean nocopy = null;
                PropagationMode propagationMode = PropagationMode.DEFAULT_MODE;
                for (String p : flags) {
                    if (p.length() == 2) {
                        accessMode = AccessMode.valueOf(p.toLowerCase());
                    } else if ("nocopy".equals(p)) {
                        nocopy = true;
                    } else if (PropagationMode.SHARED.toString().equals(p)) {
                        propagationMode = PropagationMode.SHARED;
                    } else if (PropagationMode.SLAVE.toString().equals(p)) {
                        propagationMode = PropagationMode.SLAVE;
                    } else if (PropagationMode.PRIVATE.toString().equals(p)) {
                        propagationMode = PropagationMode.PRIVATE;
                    } else {
                        seMode = SELContext.fromString(p);
                    }
                }

                return new Bind(parts[0], new Volume(parts[1]), accessMode, seMode, nocopy, propagationMode);
            }
            default: {
                throw new IllegalArgumentException();
            }
            }
        } catch (Exception e) {
            throw new IllegalArgumentException("Error parsing Bind '" + serialized + "'", e);
        }
    }
530541
def loadstr(cls, string):
        
        try:
            string = string.decode('utf-8')
        except AttributeError:
            pass

        lexer = tokenizer(string)

        if cls.is_molfile(string):
            molfile = Molfile()

            try:
                molfile.update(json.loads(string))
            except ValueError:
                molfile._build(lexer)
            return molfile

        elif cls.is_sdfile(string):
            sdfile = SDfile()

            try:
                sdfile.update(json.loads(string))
            except ValueError:
                sdfile._build(lexer)
            return sdfile

        else:
            raise ValueError('Cannot determine the format of string.')
773471
def loads(s, single=False, version=_default_version,
          strict=False, errors='warn'):
    
    ms = deserialize(s, version=version, strict=strict, errors=errors)
    if single:
        return next(ms)
    else:
        return ms
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)