Mercurial > hg > TextShaper
changeset 7:2693d9f8ed8c
add file for dealing with whitespace
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Sat, 05 Oct 2013 09:50:34 -0700 |
parents | 6e382347af17 |
children | 22c830449604 |
files | textshaper/whitespace.py |
diffstat | 1 files changed, 16 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/textshaper/whitespace.py Sat Oct 05 09:50:34 2013 -0700 @@ -0,0 +1,16 @@ +#!/usr/bin/env python + +""" +text shaping functionality having to do with whitespace +""" + +__all__ = ['normalize'] + +def normalize(text, separator=None, joiner=None): + """ + strips text and + replace multiple whitespace occurance with single occurance + """ + if joiner is None: + joiner = ' ' if separator is None else separator + return joiner.join(text.strip().split(separator))