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


Python WordPressPost.terms_names['category']方法代码示例

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


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

示例1: parseDocument

# 需要导入模块: from wordpress_xmlrpc import WordPressPost [as 别名]
# 或者: from wordpress_xmlrpc.WordPressPost import terms_names['category'] [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
开发者ID:tl3shi,项目名称:markdown2wordpress,代码行数:47,代码来源:md2wp.py

示例2: _readMetaAndContent

# 需要导入模块: from wordpress_xmlrpc import WordPressPost [as 别名]
# 或者: from wordpress_xmlrpc.WordPressPost import terms_names['category'] [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
开发者ID:SimplifyData,项目名称:pypu,代码行数:46,代码来源:service_wp.py


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