当前位置: 首页>>代码示例>>Python>>正文


Python Post.render方法代码示例

本文整理汇总了Python中post.Post.render方法的典型用法代码示例。如果您正苦于以下问题:Python Post.render方法的具体用法?Python Post.render怎么用?Python Post.render使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在post.Post的用法示例。


在下文中一共展示了Post.render方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import render [as 别名]
def main():	

	# READ TEMPATE HTML FILES
	base_html = open("templates/base.html")
	post_html = open("templates/post.html")

	# CREATE PAGE
	page = base_html.readlines()
	posts = []

	# OPEN POST TXT FILES
	postfiles = [ f for f in listdir("posts") if isfile(join("posts",f)) ]

	for postfile in postfiles:
		temp = open("posts/" + postfile, "r")
		postlines = temp.readlines()
		post_obj = Post(postlines[0], postlines[1], postlines[2:])
		posts.append("".join(post_obj.render(post_html)))
		post_html.seek(0)
		temp.close()

	# INSERT POSTS INTO PAGE
	for i in range(len(page)):
		page[i] = page[i].replace("[[posts]]", "\n\n".join(posts))

	# WRITE PAGE TO OUTPUT HTML FILE
	final = open("output/final.html", "a+")
	final.write("".join(page))

	# CLOSE FILES
	base_html.close()
	post_html.close()
开发者ID:Grayson112233,项目名称:website-parser,代码行数:34,代码来源:main.py

示例2: render_latest_posts

# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import render [as 别名]
    def render_latest_posts(self, limit):
        accu = ''
        for post_path in self.latest_posts(limit):
            post = Post(post_path)
            accu += post.render('short-post')

        output = open(os.path.join(
            self.__render_base_path, 'latest_posts.rst'), 'w')
        output.write(accu)
        output.close()
开发者ID:Armada651,项目名称:mpc-hc.org,代码行数:12,代码来源:webblog.py

示例3: render_latest_posts

# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import render [as 别名]
    def render_latest_posts(self, limit):
        accu = ''
        for post_path in self.latest_posts(limit):
            post = Post(post_path)
            accu += post.render("short-post")

        output = open(os.path.join(
            self.__render_base_path, "latest_posts.rst"), "w", encoding='utf-8')
        output.write(accu)
        output.close()
开发者ID:mplayer2,项目名称:mplayer2.org,代码行数:12,代码来源:webblog.py

示例4: render_archive

# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import render [as 别名]
    def render_archive(self):
        accu = 'Archive\n=======\n\n'
        tmpl_file = open(os.path.join(
            os.path.dirname(os.path.realpath(__file__)),
            'templates', '%s.rst' % 'archive-subtitle'))
        template = Template(tmpl_file.read())
        tmpl_file.close()

        for key in self.posts_archive():
            year = key.split("/")[0]
            month = self.__months[int(key.split("/")[1])-1]
            accu += template.render(title="%s %s" % (month, year))
            for post_path in self.posts_archive()[key]:
                post = Post(post_path)
                accu += post.render("title-post")

        output = open(os.path.join(
            self.__render_base_path, "archive.rst"), "w")
        output.write(accu)
        output.close()
开发者ID:jeeb,项目名称:site-designs,代码行数:22,代码来源:webblog.py

示例5: render_archive

# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import render [as 别名]
    def render_archive(self):
        accu = 'Archive\n=======\n\n'
        tmpl_file = open(os.path.join(
            os.path.dirname(os.path.realpath(__file__)),
            'templates', '%s.rst' % 'archive-subtitle'))
        template = Template(tmpl_file.read())
        tmpl_file.close()

        monthkey = None
        for post_path in self.posts():
            post = Post(post_path)
            if post.date_key != monthkey:
                monthkey = post.date_key
                year = monthkey.split('/')[0]
                month = self.__months[int(monthkey.split('/')[1]) - 1]
                accu += template.render(title="%s %s" % (month, year))
            accu += post.render('title-post')

        output = open(os.path.join(
            self.__render_base_path, 'archive.rst'), 'w')
        output.write(accu)
        output.close()
开发者ID:Armada651,项目名称:mpc-hc.org,代码行数:24,代码来源:webblog.py


注:本文中的post.Post.render方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。