@contextmanager
    def writing(self):
        """Return a context manager that yields a generator.

        Calling this method clears the contents of the backing store
        before returning a stream that writes to the store.
        """
        log.debug("opening for writing: %r" % self)
        with self.open_write() as stream:
            gen = _sink(self.write, stream)
            try:
                yield gen
            finally:
                gen.close()


# TODO: add more to the repr and test.
dataset/ETHPy150Open cjerdonek/open-rcv/openrcv/streams.py/StreamResourceBase.writing/original