view 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
line wrap: on
line source

#!/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))