diff options
author | R. Tyler Ballance <tyler@slide.com> | 2009-06-27 23:37:23 -0700 |
---|---|---|
committer | R. Tyler Ballance <tyler@slide.com> | 2009-06-27 23:37:23 -0700 |
commit | 899407bee3e372615b840c59b3eb25824250d7b0 (patch) | |
tree | ee83a5911a038431309747a2cb1eb9519e98114e | |
parent | 633d5bbeb004fe61d1d57d20a33701c860841f77 (diff) | |
download | python-cheetah-899407bee3e372615b840c59b3eb25824250d7b0.tar.gz |
Cleanup the Indenter class a bit, make it a wee bit faster to initialize
-rw-r--r-- | src/Filters.py | 5 | ||||
-rw-r--r-- | src/Utils/Indenter.py | 35 |
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 |