Beispiel #1
0
def time_tal(fn, count):
    p = HTMLTALParser()
    p.parseFile(fn)
    program, macros = p.getCode()
    engine = DummyEngine(macros)
    engine.globals = data
    tal = TALInterpreter(program, macros, engine, StringIO(), wrap=0,
                         tal=1, strictinsert=0)
    return time_apply(tal, (), {}, count)
Beispiel #2
0
def profile_tal(fn, count, profiler):
    p = HTMLTALParser()
    p.parseFile(fn)
    program, macros = p.getCode()
    engine = DummyEngine(macros)
    engine.globals = data
    tal = TALInterpreter(program, macros, engine, StringIO(), wrap=0,
                         tal=1, strictinsert=0)
    for i in range(4):
        tal()
    r = [None] * count
    for i in r:
        profiler.runcall(tal)
Beispiel #3
0
def time_tal(fn, count):
    p = HTMLTALParser()
    p.parseFile(fn)
    program, macros = p.getCode()
    engine = DummyEngine(macros)
    engine.globals = data
    tal = TALInterpreter(program,
                         macros,
                         engine,
                         StringIO(),
                         wrap=0,
                         tal=1,
                         strictinsert=0)
    return time_apply(tal, (), {}, count)
Beispiel #4
0
def profile_tal(fn, count, profiler):
    p = HTMLTALParser()
    p.parseFile(fn)
    program, macros = p.getCode()
    engine = DummyEngine(macros)
    engine.globals = data
    tal = TALInterpreter(program,
                         macros,
                         engine,
                         StringIO(),
                         wrap=0,
                         tal=1,
                         strictinsert=0)
    for i in range(4):
        tal()
    r = [None] * count
    for i in r:
        profiler.runcall(tal)
Beispiel #5
0
 def evaluatePathOrVar(self, expr):
     if expr == 'here/currentTime':
         return {'hours'  : 6,
                 'minutes': 59,
                 'ampm'   : 'PM',
                 }
     elif expr == 'context/@@object_name':
         return '7'
     elif expr == 'request/submitter':
         return '*****@*****.**'
     return DummyEngine.evaluatePathOrVar(self, expr)
Beispiel #6
0
def test():
    import sys
    p = TALParser()
    file = "tests/input/test01.xml"
    if sys.argv[1:]:
        file = sys.argv[1]
    p.parseFile(file)
    program, macros = p.getCode()
    from TALInterpreter import TALInterpreter
    from DummyEngine import DummyEngine
    engine = DummyEngine(macros)
    TALInterpreter(program, macros, engine, sys.stdout, wrap=0)()
Beispiel #7
0
 def __init__(self, macros=None):
     DummyEngine.__init__(self, macros)
     self.translationService = TestTranslations()