# HG changeset patch # User Jeff Hammel # Date 1380991834 25200 # Node ID 2693d9f8ed8c5040952ab33fa1f52b7fb7608fec # Parent 6e382347af17f33cfe328ec8312da45d93054b3b add file for dealing with whitespace diff -r 6e382347af17 -r 2693d9f8ed8c textshaper/whitespace.py --- /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))