diff options
Diffstat (limited to 'python/qpid/util.py')
-rw-r--r-- | python/qpid/util.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/python/qpid/util.py b/python/qpid/util.py index d03a9bd7e9..1140cbe5ef 100644 --- a/python/qpid/util.py +++ b/python/qpid/util.py @@ -17,7 +17,7 @@ # under the License. # -import os, socket, time +import os, socket, time, textwrap def connect(host, port): sock = socket.socket() @@ -65,3 +65,14 @@ def notify(condition, action=lambda: None): condition.notifyAll() finally: condition.release() + +def fill(text, indent, heading = None): + sub = indent * " " + if heading: + if not text: + return (indent - 2) * " " + heading + init = (indent - 2) * " " + heading + " -- " + else: + init = sub + w = textwrap.TextWrapper(initial_indent = init, subsequent_indent = sub) + return w.fill(" ".join(text.split())) |