reader.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:pelican-frontmark 作者: noirbizarre 项目源码 文件源码
def loader_class(self):
        class FrontmarkLoader(yaml.Loader):
            '''
            Custom YAML Loader for frontmark

            - Mapping order is respected (wiht OrderedDict)
            '''
            def construct_mapping(self, node, deep=False):
                '''User OrderedDict as default for mappings'''
                return collections.OrderedDict(self.construct_pairs(node))

        FrontmarkLoader.add_constructor('!md', self.yaml_markdown_constructor)
        if self.settings.get('FRONTMARK_PARSE_LITERAL', True):
            FrontmarkLoader.add_constructor(STR_TAG, self.yaml_multiline_as_markdown_constructor)
        for _, pair in frontmark_yaml_register.send(self):
            if not len(pair) == 2:
                log.warning('Ignoring YAML type (%s), expected a (tag, handler) tuple', pair)
                continue
            tag, constructor = pair
            FrontmarkLoader.add_constructor(tag, constructor)

        return FrontmarkLoader
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号