• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python composer.Composer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中yaml.composer.Composer的典型用法代码示例。如果您正苦于以下问题:Python Composer类的具体用法?Python Composer怎么用?Python Composer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: __init__

 def __init__(self, stream):
     Reader.__init__(self, stream)
     PyonYamlScanner.__init__(self)
     Parser.__init__(self)
     Composer.__init__(self)
     Constructor.__init__(self)
     Resolver.__init__(self)
开发者ID:ateranishi,项目名称:pyon,代码行数:7,代码来源:yaml_types.py


示例2: __init__

 def __init__(self, stream):
     Reader.__init__(self, stream)
     Scanner.__init__(self)
     Parser.__init__(self)
     Composer.__init__(self)
     NodeConstructor.__init__(self)
     Resolver.__init__(self)
开发者ID:opencord,项目名称:cord,代码行数:7,代码来源:markedyaml.py


示例3: __init__

 def __init__(self, stream, filename=None):
     Reader.__init__(self, stream)
     Scanner.__init__(self)
     Parser.__init__(self)
     Composer.__init__(self)
     HolderConstructor.__init__(self, filename)
     Resolver.__init__(self)
开发者ID:GigaSpaces-ProfessionalServices,项目名称:cloudify-dsl-parser,代码行数:7,代码来源:yaml_loader.py


示例4: __init__

 def __init__(self, stream, file_name=None):
     Reader.__init__(self, stream)
     Scanner.__init__(self)
     Parser.__init__(self)
     Composer.__init__(self)
     AnsibleConstructor.__init__(self, file_name=file_name)
     Resolver.__init__(self)
开发者ID:JaredPennella,项目名称:DevOps_Script,代码行数:7,代码来源:loader.py


示例5: __init__

    def __init__(self, stream):
        """
        Return an instance of this customised YAML Loader class.

        """
        Reader.__init__(self, stream)
        Scanner.__init__(self)
        Parser.__init__(self)
        Composer.__init__(self)
        NodeConstructor.__init__(self)
        Resolver.__init__(self)
开发者ID:wtpayne,项目名称:hiai,代码行数:11,代码来源:marked_yaml.py


示例6: __init__

    def __init__(self, stream):
        Reader.__init__(self, stream)
        Scanner12.__init__(self)
        Parser.__init__(self)
        Composer.__init__(self)

# PKM2014 - uses SafeConstructor instead of Constructor. This should make no
# difference, because "Is it YAML?" only gets as far as the composition stage,
# but - well: it reduces the risk of something bad happening.

#        Constructor.__init__(self)
        SafeConstructor.__init__(self)
        Resolver.__init__(self)
开发者ID:peterkmurphy,项目名称:isityaml,代码行数:13,代码来源:views.py


示例7: compose_mapping_node

 def compose_mapping_node(self, anchor):
     # the column here will point at the position in the file immediately
     # after the first key is found, which could be a space or a newline.
     # We could back this up to find the beginning of the key, but this
     # should be good enough to determine the error location.
     self.__mapping_starts.append((self.line + 1, self.column + 1))
     return Composer.compose_mapping_node(self, anchor)
开发者ID:conlini,项目名称:frozen-ansible,代码行数:7,代码来源:composer.py


示例8: compose_node

 def compose_node(parent, index):
     # the line number where the previous token has ended (plus empty lines)
     line = loader.line
     column = loader.column
     node = Composer.compose_node(loader, parent, index)
     node.__line__ = line + 1
     node.__column__ = column + 1
     node.__basename__ = basename
     node.__location__ = basename+":"+str(line + 1)
     return node
开发者ID:josteinaj,项目名称:docker-pipeline,代码行数:10,代码来源:common.py


示例9: compose_node

 def compose_node(self, parent, index):
     # the line number where the previous token has ended (plus empty lines)
     node = Composer.compose_node(self, parent, index)
     if isinstance(node, MappingNode):
         node.__datasource__ = self.name
         try:
             (cur_line, cur_column) = self.__mapping_starts.pop()
         except:
             cur_line = None
             cur_column = None
         node.__line__   = cur_line
         node.__column__ = cur_column
     return node
开发者ID:conlini,项目名称:frozen-ansible,代码行数:13,代码来源:composer.py


示例10: compose_node

        def compose_node(parent, index):
            # the line number where the previous token has ended (plus empty lines)
            line = loader.line
            node = Composer.compose_node(loader, parent, index)

            # TODO(jroovers): special case -> document better
            if isinstance(node.value, list) and len(node.value) > 0:
                if not isinstance(node.value[0], tuple):
                    # Processing a real yaml list -> substract 1
                    for list_node in node.value:
                        list_node.value['__line__'] -= 1

            node.value = {"__line__": line, "__val__": node.value}

            return node
开发者ID:j05h,项目名称:yamlpal,代码行数:15,代码来源:yaml_parser.py


示例11: compose_node

        def compose_node(parent, index):
            """ Invoked when a new node (key, value or compound (dict, list) type) is created. """
            line = loader.line  # the line number where the previous token has ended (plus empty lines)

            # If we get an alias, just return the alias event, we then know how to handle it in construct_object.
            # This allows us to not follow aliases which is handy in many cases.
            # https://github.com/yaml/pyyaml/blob/a7daab723352e68a209479b781b2f03c47e5179a/lib/yaml/composer.py#L64
            if loader.check_event(AliasEvent):
                event = loader.get_event()
                event.line = line  # Do make sure we associate a line number with the alias
                return event

            # call the original compose_node
            node = Composer.compose_node(loader, parent, index)

            # In case we are dealing with a yaml list, the line numbers turn out to be off by 1 which we need to fix.
            # What the parser will do is first invoke this method with every item in the list and then invoke it again
            # with the entire list. At that point we can iterate over the list and substract 1 from the line numbers
            # of the items in the list.
            # For single items in a list, Composer.compose_node(...) returns a ScalarNode. node.value is then of type
            # str, int, float, etc. For the entire list, Composer.compose_node(...) will return a SequenceNode with
            # node.value being of type 'list'. So by checking for the type of node.value, we can figure out whether
            # we are currently processing an item in a list or the actual list itself.
            # The only additional required check is making sure that in case node.value is a list, the items in
            # node.value are not tuples (because if they are, we are dealing with a nested dictionary instead of a
            # normal list). We can do this by checking whether node.value[0] is an instance of tuple or not.
            if isinstance(node.value, list) and len(node.value) > 0:
                if not isinstance(node.value[0], tuple):
                    # We're processing a real yaml list -> substract 1 from the line numbers in the list
                    for list_node in node.value:
                        list_node.value['__line__'] -= 1

            if not isinstance(node.value, dict):
                # replace the value of the node with a dictionary that contains both the line number and value
                node.value = {"__line__": line, "__val__": node.value}

            return node
开发者ID:jorisroovers,项目名称:yamlpal,代码行数:37,代码来源:yaml_parser.py


示例12: compose_node

 def compose_node(parent, index):
     # the line number where the previous token has ended (plus empty lines)
     line = loader.line
     node = Composer.compose_node(loader, parent, index)
     node.__line__ = line + 1
     return node
开发者ID:Lowess,项目名称:ansible-lint,代码行数:6,代码来源:utils.py


示例13: compose_node

 def compose_node(self, parent, index):
     # the line number where the previous token has ended (plus empty lines)
     node = Composer.compose_node(self.loader, parent, index)
     return node
开发者ID:inwotep,项目名称:lava-dispatcher,代码行数:4,代码来源:device.py


示例14: compose_node

 def compose_node(parent, index):
     node = Composer.compose_node(loader, parent, index)
     self.parse_message(node, loader.line)
     return node
开发者ID:bluedynamics,项目名称:yafowil.lingua,代码行数:4,代码来源:extractor.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python constructor.SafeConstructor类代码示例发布时间:2022-05-26
下一篇:
Python yaml.SafeLoader类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap