summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorR. Tyler Ballance <tyler@slide.com>2009-06-28 14:37:23 +0800
committerJames Abbatiello <abbeyj@gmail.com>2009-06-29 00:39:18 +0800
commit168e65b497ceea597584b3256a11a37118bf9fa0 (patch)
treecfd2ab3d02a884745f0bff393ac16f73db0a7fdc
parent81cc41cabf295e6e71f5a89e6d18c286cf8475a6 (diff)
downloadpython-cheetah-168e65b497ceea597584b3256a11a37118bf9fa0.tar.gz
Cleanup the Indenter class a bit, make it a wee bit faster to initialize
Signed-off-by: James Abbatiello <abbeyj@gmail.com>
-rw-r--r--src/Filters.py5
-rw-r--r--src/Utils/Indenter.py35
2 files changed, 13 insertions, 27 deletions
diff --git a/src/Filters.py b/src/Filters.py
index 9b9a416..3c6c688 100644
--- a/src/Filters.py
+++ b/src/Filters.py
@@ -23,10 +23,7 @@ class Filter(object):
"""
self.template = template
- def filter(self, val,
- encoding=None,
- str=str,
- **kw):
+ def filter(self, val, encoding=None, str=str, **kw):
'''
Pass Unicode strings through unmolested, unless an encoding is specified.
'''
diff --git a/src/Utils/Indenter.py b/src/Utils/Indenter.py
index 91f50ed..52c142d 100644
--- a/src/Utils/Indenter.py
+++ b/src/Utils/Indenter.py
@@ -1,5 +1,5 @@
-# $Id: Indenter.py,v 1.7 2006/01/08 01:09:30 tavis_rudd Exp $
-"""Indentation maker.
+"""
+Indentation maker.
@@TR: this code is unsupported and largely undocumented ...
This version is based directly on code by Robert Kuzelj
@@ -8,18 +8,7 @@ attributes have been renamed. Indentation is output via
$self._CHEETAH__indenter.indent() to prevent '_indenter' being looked up on the
searchList and another one being found. The directive syntax will
soon be changed somewhat.
-
-Meta-Data
-================================================================================
-Author: Mike Orr <iron@mso.oz.net>
-License: This software is released for unlimited distribution under the
- terms of the MIT license. See the LICENSE file.
-Version: $Revision: 1.7 $
-Start Date: 2001/11/07
-Last Revision Date: $Date: 2006/01/08 01:09:30 $
"""
-__author__ = "Mike Orr <iron@mso.oz.net>"
-__revision__ = "$Revision: 1.7 $"[11:-2]
import re
import sys
@@ -27,7 +16,7 @@ import sys
def indentize(source):
return IndentProcessor().process(source)
-class IndentProcessor:
+class IndentProcessor(object):
"""Preprocess #indent tags."""
LINE_SEP = '\n'
ARGS = "args"
@@ -88,15 +77,16 @@ class IndentProcessor:
return self.LINE_SEP.join(result)
-class Indenter:
- """A class that keeps track of the current indentation level.
+class Indenter(object):
+ """
+ A class that keeps track of the current indentation level.
.indent() returns the appropriate amount of indentation.
"""
- def __init__(self):
- self.On = 1
- self.Level = 0
- self.Chars = " "*4
- self.LevelStack = []
+ On = 1
+ Level = 0
+ Chars = ' '
+ LevelStack = []
+
def on(self):
self.On = 1
def off(self):
@@ -129,6 +119,5 @@ class Indenter:
def indent(self, _default=0):
if self.On:
return self.Chars * self.Level
- else:
- return " " * _default
+ return " " * _default