diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2006-11-18 00:55:14 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2006-11-18 00:55:14 +0000 |
commit | 7eac34bd827a82074cd45b285da8c9ca13d0d8b5 (patch) | |
tree | f617d36be2720397385b2df477df937e06a2a68e /lib/mako/util.py | |
parent | 6bacfd878a539655beea0ef354202cc9b0837337 (diff) | |
download | external_python_mako-7eac34bd827a82074cd45b285da8c9ca13d0d8b5.tar.gz external_python_mako-7eac34bd827a82074cd45b285da8c9ca13d0d8b5.tar.bz2 external_python_mako-7eac34bd827a82074cd45b285da8c9ca13d0d8b5.zip |
adding TemplateNode as lead parsetree value
Diffstat (limited to 'lib/mako/util.py')
-rw-r--r-- | lib/mako/util.py | 32 |
1 files changed, 1 insertions, 31 deletions
diff --git a/lib/mako/util.py b/lib/mako/util.py index 74ff01b..bdcbe4c 100644 --- a/lib/mako/util.py +++ b/lib/mako/util.py @@ -1,5 +1,4 @@ -from StringIO import StringIO -import re, string + try: Set = set except: @@ -7,32 +6,3 @@ except: Set = sets.Set -def adjust_whitespace(text): - state = [False, False] - (backslashed, triplequoted) = (0, 1) - def in_multi_line(line): - current_state = (state[backslashed] or state[triplequoted]) - if re.search(r"\\$", line): - state[backslashed] = True - else: - state[backslashed] = False - triples = len(re.findall(r"\"\"\"|\'\'\'", line)) - if triples == 1 or triples % 2 != 0: - state[triplequoted] = not state[triplequoted] - return current_state - - def _indent_line(line, stripspace = ''): - return re.sub(r"^%s" % stripspace, '', line) - - stream = StringIO() - stripspace = None - - for line in re.split(r'\r?\n', text): - if in_multi_line(line): - stream.write(line + "\n") - else: - line = string.expandtabs(line) - if stripspace is None and re.search(r"^[ \t]*[^# \t]", line): - stripspace = re.match(r"^([ \t]*)", line).group(1) - stream.write(_indent_line(line, stripspace) + "\n") - return stream.getvalue() |