Save contents of stream to this file.

        :param obj: ObjectVersion instance from where this file is accessed
            from.
        :param stream: File-like stream.
481764
def set_contents(self, stream, chunk_size=None, size=None, size_limit=None,
                     progress_callback=None, **kwargs):
        
        self.set_uri(
            *self.storage(**kwargs).save(
                stream, chunk_size=chunk_size, size=size,
                size_limit=size_limit, progress_callback=progress_callback))
1059496
def stream_object_data(self, ref):
		""""""
		cmd = self.__get_persistent_cmd("cat_file_all", "cat_file", batch=True)
		hexsha, typename, size = self.__get_object_header(cmd, ref)
		return (hexsha, typename, size, self.CatFileContentStream(size, cmd.stdout))
65584
def save(self, obj):
        
        if isinstance(obj, self.np.ndarray) and not obj.dtype.hasobject:
            # Compute a hash of the object
            # The update function of the hash requires a c_contiguous buffer.
            if obj.shape == ():
                # 0d arrays need to be flattened because viewing them as bytes
                # raises a ValueError exception.
                obj_c_contiguous = obj.flatten()
            elif obj.flags.c_contiguous:
                obj_c_contiguous = obj
            elif obj.flags.f_contiguous:
                obj_c_contiguous = obj.T
            else:
                # Cater for non-single-segment arrays: this creates a
                # copy, and thus aleviates this issue.
                # XXX: There might be a more efficient way of doing this
                obj_c_contiguous = obj.flatten()

            # memoryview is not supported for some dtypes, e.g. datetime64, see
            # https://github.com/numpy/numpy/issues/4983. The
            # workaround is to view the array as bytes before
            # taking the memoryview.
            self._hash.update(
                self._getbuffer(obj_c_contiguous.view(self.np.uint8)))

            # We store the class, to be able to distinguish between
            # Objects with the same binary content, but different
            # classes.
            if self.coerce_mmap and isinstance(obj, self.np.memmap):
                # We don't make the difference between memmap and
                # normal ndarrays, to be able to reload previously
                # computed results with memmap.
                klass = self.np.ndarray
            else:
                klass = obj.__class__
            # We also return the dtype and the shape, to distinguish
            # different views on the same data with different dtypes.

            # The object will be pickled by the pickler hashed at the end.
            obj = (klass, ('HASHED', obj.dtype, obj.shape, obj.strides))
        elif isinstance(obj, self.np.dtype):
            # Atomic dtype objects are interned by their default constructor:
            # np.dtype('f8') is np.dtype('f8')
            # This interning is not maintained by a
            # pickle.loads + pickle.dumps cycle, because __reduce__
            # uses copy=True in the dtype constructor. This
            # non-deterministic behavior causes the internal memoizer
            # of the hasher to generate different hash values
            # depending on the history of the dtype object.
            # To prevent the hash from being sensitive to this, we use
            # .descr which is a full (and never interned) description of
            # the array dtype according to the numpy doc.
            klass = obj.__class__
            obj = (klass, ('HASHED', obj.descr))
        Hasher.save(self, obj)
1165815
def save_codeobject(self, obj):
        
        if self.dump_code:
            print(obj.co_name)
            dis.dis(obj.co_code)
        self.save_reduce(types.CodeType, self._extract_code_args(obj), obj=obj)
1175123
def save_obj(self, path, update_normals=True):
        
        if update_normals:
            self.update_normals()

        # Create triangle_list
        vectors_key_list = []
        vectors_list = []
        normals_key_list = []
        normals_list = []
        triangle_list = []
        for i, vector in enumerate(self.vectors):
            one_triangle = []
            for j in range(3):
                v_key = ",".join(map(str, self.vectors[i][j][:3]))
                if v_key in vectors_key_list:
                    v_index = vectors_key_list.index(v_key)
                else:
                    v_index = len(vectors_key_list)
                    vectors_key_list.append(v_key)
                    vectors_list.append(self.vectors[i][j][:3])
                one_triangle.append(v_index + 1)

            n_key = ",".join(map(str, self.normals[i][:3]))
            if n_key in normals_key_list:
                n_index = normals_key_list.index(n_key)
            else:
                n_index = len(normals_key_list)
                normals_key_list.append(n_key)
                normals_list.append(self.normals[i][:3])

            # print(normals_list)
            triangle_list.append((one_triangle, n_index + 1))

        with open(path, "wb") as fh:
            print("# {} {}".format(__title__, __version__), file=fh)
            print("# {}".format(datetime.datetime.now()), file=fh)
            print("# {}".format(__url__), file=fh)
            print("", file=fh)
            for v in vectors_list:
                print("v {} {} {}".format(v[0], v[1], v[2]), file=fh)
            for vn in normals_list:
                print("vn {} {} {}".format(vn[0], vn[1], vn[2]), file=fh)
            for t in triangle_list:
                faces = t[0]
                normal = t[1]

                print("f {}//{} {}//{} {}//{}".format(
                    faces[0], normal,
                    faces[1], normal,
                    faces[2], normal,
                ), file=fh)
1206124
public static void serializeToDisk( File file, Object obj ) throws IOException {
        byte[] serializedObj = serialize(obj);
        try (RandomAccessFile raFile = new RandomAccessFile(file, "rw")) {
            raFile.write(serializedObj);
        }
    }
1188824
def save_object(self, obj):
        
        obj.save()
        try:
            save_object(obj, editor=self)
        except DisciplineException:
            pass
665518
def put_stream(self, bucket, label, stream_object, params={}):
        '''  '''
        self.claim_bucket(bucket) 
        self.connection.put_object(bucket, label, stream_object,
                                   headers=self._convert_to_meta(params))
670046
def stream_data(self, ostream):
        """"""
        istream = self.repo.odb.stream(self.binsha)
        stream_copy(istream, ostream)
        return self
1216528
private void writeObject(ObjectOutputStream stream)
            throws IOException
            {
        // Try to compute the time correctly, for the future (stream
        // version 2) in which we don't write out fields[] or isSet[].
        if (!isTimeSet) {
            try {
                updateTime();
            }
            catch (IllegalArgumentException e) {}
        }

        // Write out the 1.1 FCS object.
        stream.defaultWriteObject();
            }
1139515
def bwrite(stream, obj):
    
    handle = None
    if not hasattr(stream, "write"):
        stream = handle = open(stream, "wb")
    try:
        stream.write(bencode(obj))
    finally:
        if handle:
            handle.close()
352299
def save(obj, filename, protocol=4):
    

    with open(filename, 'wb') as f:
        pickle.dump(obj, f, protocol=protocol)
24788
def dump(obj, file_path, prettify=False):
    
    with open(file_path, 'w') as fp:
        fp.write(dumps(obj))
1134906
def save_object(self, obj):
        
        self.session.add(obj)
        self.session.flush()
        return obj
514436
def save(self, obj, id_code):
        
        filestream = open('{0}/{1}'.format(self.data_path, id_code), 'w+')
        pickle.dump(obj, filestream)
        filestream.close()
307939
def _from_stream(cls, stream, blob, filename=None):
        
        image_header = _ImageHeaderFactory(stream)
        if filename is None:
            filename = 'image.%s' % image_header.default_ext
        return cls(blob, filename, image_header)
1240859
public static File toFile(Object obj) throws PageException {
	if (obj instanceof File) return (File) obj;
	return FileUtil.toFile(Caster.toString(obj));
    }