diff textshaper/whitespace.py @ 36:55e0579e2143

STUB: textshaper/main.py textshaper/whitespace.py
author Jeff Hammel <k0scist@gmail.com>
date Sat, 03 May 2014 14:47:16 -0700
parents c23782a7b7ba
children
line wrap: on
line diff
--- a/textshaper/whitespace.py	Thu Mar 13 13:53:41 2014 -0700
+++ b/textshaper/whitespace.py	Sat May 03 14:47:16 2014 -0700
@@ -5,8 +5,9 @@
 """
 
 import os
+from .decorator import lines
 
-__all__ = ['normalize']
+__all__ = ['normalize', 'underscore', 'filename2name']
 
 def normalize(text, separator=None, joiner=None):
     """
@@ -18,6 +19,15 @@
     return joiner.join(text.strip().split(separator))
 
 
+@lines
+def underscore(text, replacement='_', split=None, strip=str.rstrip):
+    retval = []
+    for line in text:
+        if strip:
+            strip(line)
+        retval.append(replacement.join(line.split(split)))
+    return retval
+
 def filename2name(text, whitespace=('_',), replacement=' '):
     """
     convert filename to name