def _flush(self, auto=True, bookmark=None):
        if auto and not self.autoflush:
            return
        while self.writebuf and \
                (len(self.writebuf) >= self.chunksize or not auto):
            self.chunkidx += 1
            assert(self.chunkidx == len(self.chunks))
            chunkpos = self.pos-len(self.writebuf)
            chunkname = '%s%08x' % (self.prefix, chunkpos)
            chunkbookmark = None
            if bookmark and len(self.writebuf) <= self.chunksize:
                chunkname += ','+urlsafe_b64encode(bookmark)
                chunkbookmark = bookmark
            self.zip.writestr(chunkname, self.writebuf[:self.chunksize])
            self.writebuf = self.writebuf[self.chunksize:]
            self.chunks.append(ChunkInfo(name=chunkname,
                                         pos=chunkpos,
                                         bookmark=chunkbookmark))
From http://stackoverflow.com/a/13287083 (thanks J.F. Sebastian).
dataset/ETHPy150Open nandhp/python-imdb/imdb/chunkedfile.py/ChunkedFile._flush--crossover with--dataset/ETHPy150Open hut8labs/diffscuss/diffscuss/dates.py/utc_to_local