* Added str_snippet() from MnO ipython script.

master
wirawan 13 years ago
parent c675077620
commit ceeafa811a
  1. 15
      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 # wpylib.text_tools
# Created: 20091204 # Created: 20091204
@ -7,6 +7,12 @@
# Simple and dirty text tools # Simple and dirty text tools
# #
"""
wpylib.text_tools
Frequently used text tools.
"""
import numpy import numpy
from wpylib.sugar import ifelse from wpylib.sugar import ifelse
@ -74,6 +80,13 @@ def str_unindent(S, amount=None):
return "\n".join(rslt) 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): def str_save_to_file(filename, s1, *more_str, **opts):
"""Save one or more string (or iterables) to a file with a given file. """Save one or more string (or iterables) to a file with a given file.

Loading…
Cancel
Save