Exemple #1
0
def translate(task_name, tmpl_path, out_path, parser):
    eng = Engine()
    module = eng.load_file(tmpl_path, parser)
    path = module.path
    eng.make()
    outp = eng.modules[path].main(
        {"banner": "This file was generated by dotfiler; do not edit"})
    with open(out_path, "w") as f:
        f.write(outp)
    log.success(task_name + ": generated: " + out_path)
Exemple #2
0
def translate(task_name, tmpl_path, out_path, parser):
    eng = Engine()
    module = eng.load_file(tmpl_path, parser)
    path = module.path
    eng.make()
    outp = eng.modules[path].main({
        "banner": "This file was generated by dotfiler; do not edit"
    })
    with open(out_path, "w") as f:
        f.write(outp)
    log.success(task_name + ": generated: " + out_path)
Exemple #3
0
	def do_test(self, test_directory, template_file, param_file = "", out_file = None, includes = []):
		engine = Engine()
		directory = os.path.join("tests/", test_directory)

		(template_path, param_path, out_path) = map(
			lambda x : os.path.join(directory, x),
			(template_file, param_file, out_file))

		includes = list(map(lambda x : os.path.join(directory, x), includes))

		engine.add_includes(includes)
		path = engine.load_file(template_path).path
		engine.make()
		params = {}

		if param_file and os.path.exists(param_path):
			f = open(param_path)
			params = eval(f.read())
			f.close()

		output = engine.modules[path].main(**params)

		if out_file and os.path.exists(out_path):
			f = open(out_path)
			expected = f.read()
			self.assertEqual(expected, output)
			f.close()
		else:
			print("wrote output to file {}".format(out_path))
			f = open(out_path, "w")
			f.write(output)
			f.close()

		print("template {} generated output:\n".format(template_path))
		print(output)
Exemple #4
0
    def do_test(self,
                test_directory,
                template_file,
                param_file="",
                out_file=None,
                includes=[]):
        engine = Engine()
        directory = os.path.join("tests/", test_directory)

        (template_path, param_path,
         out_path) = map(lambda x: os.path.join(directory, x),
                         (template_file, param_file, out_file))

        includes = list(map(lambda x: os.path.join(directory, x), includes))

        engine.add_includes(includes)
        path = engine.load_file(template_path).path
        engine.make()
        params = {}

        if param_file and os.path.exists(param_path):
            f = open(param_path)
            params = eval(f.read())
            f.close()

        output = engine.modules[path].main(**params)

        if out_file and os.path.exists(out_path):
            f = open(out_path)
            expected = f.read()
            self.assertEqual(expected, output)
            f.close()
        else:
            print("wrote output to file {}".format(out_path))
            f = open(out_path, "w")
            f.write(output)
            f.close()

        print("template {} generated output:\n".format(template_path))
        print(output)