comparison textshaper/whitespace.py @ 7:2693d9f8ed8c

add file for dealing with whitespace
author Jeff Hammel <jhammel@mozilla.com>
date Sat, 05 Oct 2013 09:50:34 -0700
parents
children 22c830449604
comparison
equal deleted inserted replaced
6:6e382347af17 7:2693d9f8ed8c
1 #!/usr/bin/env python
2
3 """
4 text shaping functionality having to do with whitespace
5 """
6
7 __all__ = ['normalize']
8
9 def normalize(text, separator=None, joiner=None):
10 """
11 strips text and
12 replace multiple whitespace occurance with single occurance
13 """
14 if joiner is None:
15 joiner = ' ' if separator is None else separator
16 return joiner.join(text.strip().split(separator))