# HG changeset patch # User Gerald Klix (MGE702687) # Date 1529692612 -7200 # Fri Jun 22 20:36:52 2018 +0200 # Node ID 2ea70030c77400006ac14f6b2ad22dd79fd5a031 # Parent 74a2aeec0e81a2b85b6ba232672cdb345cc4f97c SUM: Added some things for the BEE project. diff --git a/gf/go.py b/gf/go.py --- a/gf/go.py +++ b/gf/go.py @@ -23,7 +23,8 @@ "__float__", "__int__", "AbstractObject", "Object", "FinalizingMixin", "Writer", "IndentingWriter", - "spy", "as_string", "push", "pop", "indent", "dedent", + "spy", "as_string", "as_indented_string", "get_text", + "push", "pop", "indent", "dedent", "CSep", "csep", ] @@ -458,6 +459,18 @@ __out__(self, writer) return get_text(writer) +@generic +def as_indented_string(self): + """Answer an object's indented string. + + This is done by creating a :class:`IndentingWriter` instance + and calling the :func:`__out__` generic with the + object and the writer. The using :meth:`Writer.get_text` + to retrieve the text written.""" + writer = IndentingWriter() + __out__(self, writer) + return get_text(writer) + __out__ = generic("__out__", "Create a print string of an object using a :class:`Writer`.")