def visitInclude(self, node): path = os.path.join(self.options.get("basedir", os.getcwd()), node.path) if os.path.exists(path): src = open(path, 'r').read() elif os.path.exists("%s.pug" % path): src = open("%s.pug" % path, 'r').read() else: raise Exception("Include path doesn't exists") parser = pypugjs.parser.Parser(src) block = parser.parse() self.visit(block)
def test_guess_is_made_without_encoding(self): with tempfile.NamedTemporaryFile() as file: file.write("我没有埋怨,磋砣的只是一些时间。".encode("utf-32")) file.seek(0) with runtime.open(file.name) as handle: self.assertEqual(handle.encoding, "utf_32")
def test_encoding_taken_directly(self): """If an encoding is given, we don't try to make a guess.""" with tempfile.NamedTemporaryFile() as file: file.write("✔️¿¿«Not valid Latin-1»??".encode("utf-8")) file.seek(0) with runtime.open(file.name, encoding="latin1") as handle: self.assertEqual(handle.read(), "â\x9c\x94ï¸\x8f¿¿«Not valid Latin-1»??")
def visitInclude(self, node): path = os.path.join(self.options.get("basedir", '.'), self.format_path(node.path)) if os.path.exists(path): src = open(path, 'r').read() else: raise Exception("Include path doesn't exists ({})".format(path)) parser = pypugjs.parser.Parser(src) block = parser.parse() self.visit(block)
def visitInclude(self, node): path = os.path.join( self.options.get("basedir", '.'), self.format_path(node.path) ) if os.path.exists(path): src = open(path, 'r').read() else: raise Exception("Include path doesn't exists ({})".format(path)) parser = pypugjs.parser.Parser(src) block = parser.parse() self.visit(block)