Ejemplo n.º 1
0
 def __init__(self, tokenizer, autoescape=False):
     self.tokenizer = tokenizer
     self.functions = defaultdict(list)
     self.functions['__main__()'] = []
     self.mod_py = [] # module-level python blocks
     self.iterator = iter(self.tokenizer)
     self.autoescape = autoescape
     self._in_def = False
     self._is_child = False
Ejemplo n.º 2
0
 def __init__(self, filename, doc, mode='xml', is_fragment=False, force_mode=False):
     self.filename = filename
     self.doc = doc
     self.mode = mode
     self.functions = defaultdict(list)
     self.functions['__main__()'] = []
     self.function_lnos = {}
     self.mod_py = []
     self.in_def = False
     self.is_child = False
     self.is_fragment = is_fragment
     if not force_mode and self.doc.doctype:
         if self.doc.doctype.toxml().lower() == '<!doctype html>':
             self.mode = 'html5'
         elif self.doc.doctype.systemId is None:
             self.mode = 'html'
         else:
             self.mode = self.mode_lookup.get(
                 self.doc.doctype.systemId, 'xml')