strings.py
34 lines
| 1.1 KiB
| text/x-python
|
PythonLexer
/ utils / strings.py
Jonathan Frederic
|
r10433 | """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): | |||
Jonathan Frederic
|
r10434 | """ Intelligently wrap text""" | |
Jonathan Frederic
|
r10433 | ||
splitt = text.split('\n') | |||
wrp = map(lambda x:textwrap.wrap(x,width),splitt) | |||
wrpd = map('\n'.join, wrp) | |||
Jonathan Frederic
|
r10434 | return '\n'.join(wrpd) | |
def strip_dollars(text): | |||
"""Remove all dollar symbols from text""" | |||
return text.strip('$') |