本文整理汇总了Python中wordpress_xmlrpc.WordPressPost.terms_names['post_tag']方法的典型用法代码示例。如果您正苦于以下问题:Python WordPressPost.terms_names['post_tag']方法的具体用法?Python WordPressPost.terms_names['post_tag']怎么用?Python WordPressPost.terms_names['post_tag']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wordpress_xmlrpc.WordPressPost
的用法示例。
在下文中一共展示了WordPressPost.terms_names['post_tag']方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parseDocument
# 需要导入模块: from wordpress_xmlrpc import WordPressPost [as 别名]
# 或者: from wordpress_xmlrpc.WordPressPost import terms_names['post_tag'] [as 别名]
def parseDocument(filename):
lines = open(filename, 'r').readlines()
values = {'title':'', 'permalink':'', 'layout':'post', 'tags':'', 'categories':'default', 'published': 'false'}
start = False
config = False
for i in range(len(lines)):
line = lines[i].strip()
if config == False:
if line == '---':
if (start == False):
start = True
else: # end
if (values['title'] == '' or values['permalink'] == ''):
printf('title and permalink should not be null!\n'); exit()
else:# config ok
config = True
else:
try:
key = line[:line.find(':')]
value = line[line.find(':')+1:]
values[key] = value.strip()
except:
printf('config failed! (key, value) = (' + key + ', ' + value + ')\n');exit()
else: #config ok
while len(lines[i]) <= 1: #filter first blank lines
i+=1
rawcontent = parseMedia(lines[i:])
rawfilename = filename[:-3] + '.raw.id-'
open(rawfilename, 'w').writelines(rawcontent)
post = WordPressPost()
post.title = values['title']
post.slug = values['permalink']
post.content = pandocTool.md2html(rawfilename)
post.post_type = values['layout']
post.post_status = 'publish' if values['published'].lower() == 'true' else 'draft'
post.comment_status = 'open' #default
post.pint_status = 'open' #default
post.terms_names = {}
#values['tags'] = values['tags'].replace(',', ',') compatible with jekyll, use blank
#values['categories'] = values['categories'].replace(',', ',')
if len(values['tags']) > 0:
post.terms_names['post_tag'] = [ tag.strip() for tag in values['tags'].split() if len(tag) > 0]
if len(values['categories']) > 0:
post.terms_names['category'] = [ cate.strip() for cate in values['categories'].split() if len(cate) > 0]
return post
示例2: _readMetaAndContent
# 需要导入模块: from wordpress_xmlrpc import WordPressPost [as 别名]
# 或者: from wordpress_xmlrpc.WordPressPost import terms_names['post_tag'] [as 别名]
def _readMetaAndContent(self,fid):
"""Reads meta data and content from file into WordPressPost() class.
Returns the class
If error, returns None
"""
found_meta_separator=False
d={}
# Read lines until we find the meta separator
while found_meta_separator is False:
line = fid.readline()
# Did we find the --- separator it?
if line[0:len(self.META_SEPARATOR)]==self.META_SEPARATOR:
found_meta_separator=True
else:
key=line.split(':')[0].strip().lower()
if key in self.WP_META_KEYS:
d[key]=line.split(':')[1].strip()
else:
logger.error("wp: Token '%s' not in list of known tokens %s"\
%(key,self.WP_META_KEYS))
return None
if not d.has_key('title'):
print("wp: A title: keyword is required!")
d['content']=fid.readlines()
d['content']=''.join(d['content'])
# Let's transfer over to a wordpress post class
post = WordPressPost()
post.title=d['title']
post.content=d['content']
post.post_status='publish'
post.terms_names={}
if d.has_key('tags'):
post.terms_names['post_tag']=d['tags'].split(',')
if d.has_key('category'):
post.terms_names['category']=d['category'].split(',')
return post
示例3: entry_to_wppost
# 需要导入模块: from wordpress_xmlrpc import WordPressPost [as 别名]
# 或者: from wordpress_xmlrpc.WordPressPost import terms_names['post_tag'] [as 别名]
def entry_to_wppost(entry, client):
post = WordPressPost()
# Convert entry values to Post value
post.user = get_author_by_display_name(entry.author, client)
post.date = entry.published_parsed
post.post_status = "draft"
post.title = entry.title
post.content = entry.content[0].value
post.excerpt = entry.summary
post.link = entry.link
# There is some given tags
if len(entry.tags):
entry.tags = [t.term for t in entry.tags]
# Add category (with the first tag)
post.terms_names = {
'category': entry.tags[0:1],
'post_tag': [],
}
# Add tags
if len(entry.tags) > 1: post.terms_names['post_tag'] = entry.tags[1:]
return post