예제 #1
0
 def __init__(self, environment):
     CodeGenerator.__init__(self, environment, '<introspection>',
                            '<introspection>')
     
     self._getattr_stack = 0 
     self._varstack = []
     self._undeclared = set()
예제 #2
0
파일: jinjs.py 프로젝트: sciyoshi/jinjs
 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
예제 #3
0
파일: codegen.py 프로젝트: djc/jasinja
	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(')')
예제 #4
0
 def __init__(self, environment):
     CodeGenerator.__init__(self, environment, '<introspection>',
                            '<introspection>')
     self.undeclared_identifiers = set()
예제 #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)
예제 #6
0
파일: jinjs.py 프로젝트: sciyoshi/jinjs
 def _generate(self, source, name, filename, defer_init=False):
     generator = CodeGenerator(self, name, filename)
     generator.visit(source)
     return generator.stream.getvalue()
예제 #7
0
 def __init__(self, environment):
     CodeGenerator.__init__(self, environment, '<introspection>',
                            '<introspection>')
     self.undeclared_identifiers = set()
예제 #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)
예제 #9
0
 def __init__(self, *args, **kwargs):
     CodeGenerator.__init__(self, *args, **kwargs)
     self.args = {}
     self.prototype = None
예제 #10
0
파일: codegen.py 프로젝트: djc/jasinja
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()