def _test_a_file(self, filename): normalized = os.path.normpath(filename) clean_name = os.path.relpath(normalized, self.eziodir) print >>sys.stderr, "File: %s..." % (normalized,), with open(filename) as f: pytext = tmpl2py.tmpl2py(f) # if it's not syntactically valid, this will throw a SyntaxError ast.parse(pytext) print >>sys.stderr, "Passed!"
def _test_a_file(self, filename): normalized = os.path.normpath(filename) clean_name = os.path.relpath(normalized, self.eziodir) print >>sys.stderr, "File: %s..." % (normalized,), with open(filename) as f: pytext = tmpl2py.tmpl2py(f) # if it's not syntactically valid, this will throw a SyntaxError ast_ = ast.parse(pytext) # name for the template class tmplname = re.sub("[^a-zA-Z0-9_]", "", os.path.basename(clean_name)) modnode = py2moremeaningfulpy.py2moremeaningfulpy(tmplname, ast_) # if linenumbers or ast structure is wrong, this will throw some # kind of error. Right now, this is mostly a sanity check. compile(modnode, filename, "exec") print >>sys.stderr, "Passed!"