def compile_template(template_name, output, context={}): """It takes a tempate name, renders that template and the rendered content is compiled into a plain text file inside output """ try: content = render_template(template_name, context) touch(output) with open(output, "w") as f: f.write(content) except TemplateNotFound: pass
def main(argv=None): if argv is None: argv = sys.argv[1:] parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("name", type=valid_name, help="Your blog's name") args = parser.parse_args(argv) project_name = args.name touch("%s/%s/base.html" % (project_name, templates_path)) touch("%s/%s/index.html" % (project_name, templates_path))
def test_touch_nested(self): "Test that creates directories if the don't exist and empty files" utils.touch("a/b/c") self.assertTrue(os.path.isfile("a/b/c"))
def test_touch(self): "Test that creates empty files" utils.touch("a") self.assertTrue(os.path.isfile("a"))