From ceeafa811a3c3e1b7c7ebe7ef0ed1f273c97c389 Mon Sep 17 00:00:00 2001 From: wirawan Date: Wed, 7 Sep 2011 15:03:54 +0000 Subject: [PATCH] * Added str_snippet() from MnO ipython script. --- text_tools.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/text_tools.py b/text_tools.py index c0a9df9..adfb133 100644 --- a/text_tools.py +++ b/text_tools.py @@ -1,4 +1,4 @@ -# $Id: text_tools.py,v 1.6 2011-06-03 18:24:00 wirawan Exp $ +# $Id: text_tools.py,v 1.7 2011-09-07 15:03:54 wirawan Exp $ # # wpylib.text_tools # Created: 20091204 @@ -7,6 +7,12 @@ # Simple and dirty text tools # +""" +wpylib.text_tools + +Frequently used text tools. +""" + import numpy from wpylib.sugar import ifelse @@ -74,6 +80,13 @@ def str_unindent(S, amount=None): return "\n".join(rslt) +def str_snippet(S): + """Standard processing for input snippet: + Unindent a string and strip the trailing whitespaces (mainly for input + file segments.""" + return str_unindent(S).rstrip() + + def str_save_to_file(filename, s1, *more_str, **opts): """Save one or more string (or iterables) to a file with a given file.