/usr/lib/python2.7/dist-packages/chameleon/program.py is in python-chameleon 2.24-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | try:
str = unicode
except NameError:
long = int
from .tokenize import iter_xml
from .tokenize import iter_text
from .parser import ElementParser
from .namespaces import XML_NS
from .namespaces import XMLNS_NS
class ElementProgram(object):
DEFAULT_NAMESPACES = {
'xmlns': XMLNS_NS,
'xml': XML_NS,
}
tokenizers = {
'xml': iter_xml,
'text': iter_text,
}
def __init__(self, source, mode="xml", filename=None):
tokenizer = self.tokenizers[mode]
tokens = tokenizer(source, filename)
parser = ElementParser(tokens, self.DEFAULT_NAMESPACES)
self.body = []
for kind, args in parser:
node = self.visit(kind, args)
if node is not None:
self.body.append(node)
def visit(self, kind, args):
visitor = getattr(self, "visit_%s" % kind)
return visitor(*args)
|