示例#1
0
文件: template.py 项目: anler/mdblog
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
示例#2
0
文件: init.py 项目: anler/mdblog
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))
示例#3
0
 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"))
示例#4
0
 def test_touch(self):
     "Test that creates empty files"
     utils.touch("a")
     self.assertTrue(os.path.isfile("a"))