Exemplo n.º 1
0
 def __init__(self, environment):
     CodeGenerator.__init__(self, environment, '<introspection>',
                            '<introspection>')
     
     self._getattr_stack = 0 
     self._varstack = []
     self._undeclared = set()
Exemplo n.º 2
0
 def generate(self, templates=None):
     for name in templates if templates is not None else self.get_all_templates():
         template, filename, uptodate = self.loader.get_source(self.environment, name)
         generator = CodeGenerator(self.environment, name, filename)
         source = env.parse(template, name, filename)
         generator.visit(source)
         yield generator.stream.getvalue(), name, filename
Exemplo n.º 3
0
	def visit_Compare(self, node, frame):
		
		if node.ops[0].op not in ('in', 'notin'):
			CodeGenerator.visit_Compare(self, node, frame)
			return
		
		oper = node.ops[0]
		if oper.op == 'notin':
			self.write('!')
		self.write('Jasinja.utils.contains(')
		self.visit(node.expr, frame)
		self.write(', ')
		self.visit(oper.expr, frame)
		self.write(')')
Exemplo n.º 4
0
 def __init__(self, environment):
     CodeGenerator.__init__(self, environment, '<introspection>',
                            '<introspection>')
     self.undeclared_identifiers = set()
Exemplo n.º 5
0
 def enter_frame(self, frame):
     """Remember all undeclared identifiers."""
     CodeGenerator.enter_frame(self, frame)
     for _, (action, param) in iteritems(frame.symbols.loads):
         if action == 'resolve':
             self.undeclared_identifiers.add(param)
Exemplo n.º 6
0
 def _generate(self, source, name, filename, defer_init=False):
     generator = CodeGenerator(self, name, filename)
     generator.visit(source)
     return generator.stream.getvalue()
Exemplo n.º 7
0
 def __init__(self, environment):
     CodeGenerator.__init__(self, environment, '<introspection>',
                            '<introspection>')
     self.undeclared_identifiers = set()
Exemplo n.º 8
0
 def enter_frame(self, frame):
     """Remember all undeclared identifiers."""
     CodeGenerator.enter_frame(self, frame)
     for _, (action, param) in iteritems(frame.symbols.loads):
         if action == 'resolve':
             self.undeclared_identifiers.add(param)
Exemplo n.º 9
0
 def __init__(self, *args, **kwargs):
     CodeGenerator.__init__(self, *args, **kwargs)
     self.args = {}
     self.prototype = None
Exemplo n.º 10
0
def pygen(env, name):
	src, fn, up = env.loader.get_source(env, name)
	gen = CodeGenerator(env, 'blah', 'index.html', None, False)
	gen.visit(compile(env, src))
	return gen.stream.getvalue()