##// END OF EJS Templates
Moved wrap code into Strings utility file.
Moved wrap code into Strings utility file.

File last commit:

r10433:b95ac079
r10433:b95ac079
Show More
strings.py
28 lines | 1.0 KiB | text/x-python | PythonLexer
"""String utilities.
Contains a collection of usefull string manipulations functions.
"""
#-----------------------------------------------------------------------------
# Copyright (c) 2013, the IPython Development Team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------
# Our own imports
import textwrap #TODO
#-----------------------------------------------------------------------------
# Functions
#-----------------------------------------------------------------------------
def wrap(text, width=100):
""" Try to detect and wrap paragraph"""
splitt = text.split('\n')
wrp = map(lambda x:textwrap.wrap(x,width),splitt)
wrpd = map('\n'.join, wrp)
return '\n'.join(wrpd)