本文整理汇总了Python中model.Post.update_content方法的典型用法代码示例。如果您正苦于以下问题:Python Post.update_content方法的具体用法?Python Post.update_content怎么用?Python Post.update_content使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.Post
的用法示例。
在下文中一共展示了Post.update_content方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ElementTree
# 需要导入模块: from model import Post [as 别名]
# 或者: from model.Post import update_content [as 别名]
repository = Repo.init(repository_path)
repository.index.commit('Import from Wordpress') # Commit is unnecessary.
tree = ElementTree(file=filename)
description = tree.find('.//channel/description').text
repository.description = description
author_emails = {}
for author in tree.iterfind('.//{http://wordpress.org/export/1.2/}author'):
author_name = author.find('{http://wordpress.org/export/1.2/}author_display_name').text
author_email = author.find('{http://wordpress.org/export/1.2/}author_email').text
author_emails[author_name] = author_email
for item in tree.iterfind('.//item'):
post_type = item.find('{http://wordpress.org/export/1.2/}post_type').text
status = item.find('{http://wordpress.org/export/1.2/}status').text
if post_type == 'post' and status == 'publish':
title = item.find('title').text
pubdate = item.find('pubDate').text
creator = item.find('{http://purl.org/dc/elements/1.1/}creator').text
email = author_emails[creator]
content = item.find('{http://purl.org/rss/1.0/modules/content/}encoded').text
html = "<h1>%s</h1>\n%s" % (title, content)
#comments = [c for c in item.iterfind('{http://wordpress.org/export/1.2/}comment')]
filename = item.find('{http://wordpress.org/export/1.2/}post_name').text
environ['GIT_AUTHOR_DATE'] = pubdate
post = Post(repository_path, filename.encode('utf-8'))
post.update_content(html.encode('utf-8'), creator.encode('utf-8'), \
email.encode('utf-8'), title.encode('utf-8'))