Load a serialized index
173848
def load(cls, serialized_index):
        """"""
        from lunr import __TARGET_JS_VERSION__

        if isinstance(serialized_index, basestring):
            serialized_index = json.loads(serialized_index)

        if serialized_index["version"] != __TARGET_JS_VERSION__:
            logger.warning(
                "Version mismatch when loading serialized index. "
                "Current version of lunr {} does not match that of serialized "
                "index {}".format(__TARGET_JS_VERSION__, serialized_index["version"])
            )

        field_vectors = {
            ref: Vector(elements) for ref, elements in serialized_index["fieldVectors"]
        }

        tokenset_builder = TokenSetBuilder()
        inverted_index = {}
        for term, posting in serialized_index["invertedIndex"]:
            tokenset_builder.insert(term)
            inverted_index[term] = posting

        tokenset_builder.finish()

        return Index(
            fields=serialized_index["fields"],
            field_vectors=field_vectors,
            inverted_index=inverted_index,
            token_set=tokenset_builder.root,
            pipeline=Pipeline.load(serialized_index["pipeline"]),
        )
1232731
def loads(s, encoding=None, cls=None, object_hook=None, parse_float=None,
          parse_int=None, parse_constant=None, object_pairs_hook=None):
    """"""

    assert cls is None, 'Custom decoders are not supported'

    if sys.version_info[0] < 3:
        decodable_type = type('')
    else:
        decodable_type = type(b'')
    if isinstance(s, decodable_type):
        encoding = encoding or 'utf-8'
        s = s.decode(encoding)

    if not s:
        raise ValueError('Empty strings are not legal JSON5')
    parser = Parser(s, '<string>')
    ast, err, newpos = parser.parse()
    if err:
        raise ValueError(err)

    def _fp_constant_parser(s):
        return float(s.replace('Infinity', 'inf').replace('NaN', 'nan'))

    if object_pairs_hook:
        dictify = object_pairs_hook
    elif object_hook:
        dictify = lambda pairs: object_hook(dict(pairs))
    else:
        dictify = dict

    parse_float = parse_float or float
    parse_int = parse_int or int
    parse_constant = parse_constant or _fp_constant_parser

    return _walk_ast(ast, dictify, parse_float, parse_int, parse_constant)
375625
def FromTrimmedData(data, index):
        
        header = Header()

        ms = StreamManager.GetStream(data)

        reader = BinaryReader(ms)
        header.DeserializeUnsigned(reader)
        reader.ReadByte()

        witness = Witness()
        witness.Deserialize(reader)
        header.Script = witness

        StreamManager.ReleaseStream(ms)

        return header
1315780
def load_or_create idx
      return from_redis(idx) if exists?(idx)
      obj = from_index idx
      obj.save
      obj
    end
547790
def from_string(self, serialized):
        
        self._warn_deprecated_outside_JSONField()
        value = yaml.safe_load(serialized)
        return self.enforce_type(value)
1336983
def load_object(filename):
    """"""
    logging.info('loading {}...'.format(filename))
    try:
        with gzip.GzipFile(filename, 'rb') as f:
            buf = ''
            while True:
                data = f.read()
                if data == '':
                    break
                buf += data
            return pickle.loads(buf)
    except Exception as e:
        logging.error('load failure: {}'.format(e))
        raise
924213
def load_stream(self, stream):
        
        # load the batches
        for batch in self.serializer.load_stream(stream):
            yield batch

        # load the batch order indices
        num = read_int(stream)
        batch_order = []
        for i in xrange(num):
            index = read_int(stream)
            batch_order.append(index)
        yield batch_order
406350
def deserialize(self, serialized):
        '''
        '''
        deserialized = json.loads(serialized)
        if deserialized.get('identifier') is None:
            return self._deserialize_v2(deserialized)
        else:
            return self._deserialize_v1(deserialized)
680450
def _xfs_info_get_kv(serialized):
    '''
    
    '''
    # No need to know sub-elements here
    if serialized.startswith("="):
        serialized = serialized[1:].strip()

    serialized = serialized.replace(" = ", "=*** ").replace(" =", "=")

    # Keywords has no spaces, values do
    opt = []
    for tkn in serialized.split(" "):
        if not opt or "=" in tkn:
            opt.append(tkn)
        else:
            opt[len(opt) - 1] = opt[len(opt) - 1] + " " + tkn

    # Preserve ordering
    return [tuple(items.split("=")) for items in opt]
66428
def loads(self, data, raw=False):
        '''
        
        '''
        data = self.decrypt(data)
        # simple integrity check to verify that we got meaningful data
        if not data.startswith(self.PICKLE_PAD):
            return {}
        load = self.serial.loads(data[len(self.PICKLE_PAD):], raw=raw)
        return load
1185053
public void load(AjaxRequestTarget ajaxRequestTarget, int index)
	{
		ajaxRequestTarget.appendJavaScript(this.load(index).render().toString());
	}
1028320
@Override
	protected void unserializeFrom(RawDataBuffer in)
    {
    	super.unserializeFrom(in);
    	browserId = new IntegerID(in.readInt());   
    }
911566
public void index(DigitalObject object, Payload payload) throws IndexerException {
		String oid = object.getId();
		String pid = payload.getId();

		// Don't proccess annotations through this function
		if (pid.startsWith("anotar.")) {
			annotate(object, payload);
			return;
		}
		// log.info("Indexing OID:'{}', PID: '{}'", oid, pid);

		// get the indexer properties or we can't index
		Properties props;
		try {
			props = object.getMetadata();
		} catch (StorageException ex) {
			throw new IndexerException("Failed loading properties : ", ex);
		}

		try {
			// Get the harvest files
			String confOid = props.getProperty("jsonConfigOid");
			String rulesOid = props.getProperty("rulesOid");
			String scriptType = props.getProperty("scriptType");
			String doc;
			// Generate the Solr document
			if ("groovy".equals(scriptType) || StringUtils.isBlank(scriptType)) {
				doc = indexByGroovyScript(object, payload, confOid, rulesOid, props);
			} else {
				doc = indexByPythonScript(object, payload, confOid, rulesOid, props);
			}

			// Did the indexer alter metadata?
			String toClose = props.getProperty("objectRequiresClose");
			if (toClose != null) {
				log.debug("Indexing has altered metadata, closing object.");
				props.remove("objectRequiresClose");
				object.close();
				try {
					props = object.getMetadata();
				} catch (StorageException ex) {
					throw new IndexerException("Failed loading properties : ", ex);
				}
			}

			addToBuffer(oid + "/" + pid, doc);
		} catch (Exception e) {
			log.error("Indexing failed!\n-----\n", e);
		}
	}
1012793
def marshal_load(serialised)
      self.method  = serialised[:method]
      self.body    = serialised[:body]
      self.headers = serialised[:headers]
      self.path    = serialised[:path]
      self.params  = serialised[:params]
      self.options = serialised[:options]
    end
71728
def ReadSerialized(cls, json_string):  # pylint: disable=arguments-differ
    
    if json_string:
      json_dict = json.loads(json_string)
      return cls.ReadSerializedDict(json_dict)

    return None
344591
def load():
    '''
    
    '''
    serial = salt.payload.Serial(__opts__)

    try:
        datastore_path = os.path.join(__opts__['cachedir'], 'datastore')
        with salt.utils.files.fopen(datastore_path, 'rb') as rfh:
            return serial.loads(rfh.read())
    except (IOError, OSError, NameError):
        return {}
563654
def _load_fast(filename):
        """"""
        it = json.load(open("{}_items.json".format(filename)))
        words, unk_index, name = it["items"], it["unk_index"], it["name"]
        vectors = np.load(open("{}_vectors.npy".format(filename), 'rb'))
        return words, unk_index, name, vectors