[Assorted-commits] SF.net SVN: assorted:[979] python-commons/trunk/src/commons/strs.py
Brought to you by:
yangzhang
From: <yan...@us...> - 2008-10-02 18:47:43
|
Revision: 979 http://assorted.svn.sourceforge.net/assorted/?rev=979&view=rev Author: yangzhang Date: 2008-10-02 18:47:14 +0000 (Thu, 02 Oct 2008) Log Message: ----------- added unwrap() Modified Paths: -------------- python-commons/trunk/src/commons/strs.py Modified: python-commons/trunk/src/commons/strs.py =================================================================== --- python-commons/trunk/src/commons/strs.py 2008-10-02 18:46:58 UTC (rev 978) +++ python-commons/trunk/src/commons/strs.py 2008-10-02 18:47:14 UTC (rev 979) @@ -56,3 +56,11 @@ x = x.replace(a,b) return x +def unwrap(s): + """ + Joins a bunch of lines. L{s} is either a single string (which will be + split on newlines into a list of strings) or a list of strings + (representing lines). + """ + if isinstance(s, str): s = s.strip().split('\n') + return ' '.join( line.strip() for line in s ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |