(self, key, file)
Write key to file-like object file. Either this method or
        :meth:`~simplekv.KeyValueStore._get_filename` will be called by
        :meth:`~simplekv.KeyValueStore.get_file`. Note that this method does
        not accept strings.

        :param key: Key to be retrieved
        :param file: File-like object to write to
Write key to file-like object file. Either this method or
        :meth:`~simplekv.KeyValueStore._get_filename` will be called by
        :meth:`~simplekv.KeyValueStore.get_file`. Note that this method does
        not accept strings.
Write key to file - like object file . Either this method or : meth : ~simplekv . KeyValueStore . _get_filename will be called by : meth : ~simplekv . KeyValueStore . get_file . Note that this method does not accept strings .
def _get_file(self, key, file):
        """Write key to file-like object file. Either this method or
        :meth:`~simplekv.KeyValueStore._get_filename` will be called by
        :meth:`~simplekv.KeyValueStore.get_file`. Note that this method does
        not accept strings.

        :param key: Key to be retrieved
        :param file: File-like object to write to
        """
        bufsize = 1024 * 1024

        # note: we do not use a context manager here or close the source.
        # the source goes out of scope shortly after, taking care of the issue
        # this allows us to support file-like objects without close as well,
        # such as BytesIO.
        source = self.open(key)
        try:
            while True:
                buf = source.read(bufsize)
                file.write(buf)

                if len(buf) < bufsize:
                    break
        finally:
            source.close()
def _get_file ( self , key , file ) : bufsize = 1024 * 1024 # note: we do not use a context manager here or close the source. # the source goes out of scope shortly after, taking care of the issue # this allows us to support file-like objects without close as well, # such as BytesIO. source = self . open ( key ) try : while True : buf = source . read ( bufsize ) file . write ( buf ) if len ( buf ) < bufsize : break finally : source . close ( )