Cheetah.Utils.Indenter module

Indentation maker. @@TR: this code is unsupported and largely undocumented ...

This version is based directly on code by Robert Kuzelj <robert_kuzelj@yahoo.com> and uses his directive syntax. Some classes and 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.

class Cheetah.Utils.Indenter.IndentProcessor

Bases: object

Preprocess #indent tags.

ARGS = 'args'
CHAR = 'char'
DEC = '--'
DIRECTIVE = re.compile('[ \\t]*#')
INC = '++'
INDENT_DIR = re.compile('[ \\t]*#indent[ \\t]*(?P<args>.*)')
LINE_SEP = '\n'
OFF = 'off'
ON = 'on'
POP = 'pop'
PUSH = 'push'
SET = '='
WHITESPACES = re.compile('(?P<ws>[ \\t]*)')
WS = 'ws'
process(_txt)
class Cheetah.Utils.Indenter.Indenter

Bases: object

A class that keeps track of the current indentation level. .indent() returns the appropriate amount of indentation.

Chars = ' '
Level = 0
LevelStack = []
On = 1
dec()

decrement can only be applied to values greater zero values below zero don’t make any sense at all!

inc()
indent(_default=0)
off()
on()
pop()

the levestack can not become -1. any attempt to do so sets the level to 0!

push()
setChar(_chars)
setLevel(_level)

the leve can’t be less than zero. any attempt to do so sets the level automatically to zero!

Cheetah.Utils.Indenter.indentize(source)