summaryrefslogtreecommitdiff
path: root/src/zope/tal/_talinterpreter/interplevel.py
blob: a1acd16851cf43d8ceb27d935328d002ff9026d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
from pypy.interpreter.baseobjspace import ObjSpace


def _normalize(space, text):
    # Now we need to normalize the whitespace in implicit message ids and
    # implicit $name substitution values by stripping leading and trailing
    # whitespace, and folding all internal whitespace to a single space.
    text = text.replace('\n', ' ')
    text = text.replace('\t', ' ')
    parts = [part for part in text.split(' ') if part]
    result = ' '.join(parts)
    return space.wrap(result)
_normalize.unwrap_spec = [ObjSpace, str]