(self, node)
This implements the merge key feature http://yaml.org/type/merge.html
        by inserting keys from the merge dict/list of dicts if not yet
        available in this node
This implements the merge key feature http://yaml.org/type/merge.html
        by inserting keys from the merge dict/list of dicts if not yet
        available in this node
This implements the merge key feature http : // yaml . org / type / merge . html by inserting keys from the merge dict / list of dicts if not yet available in this node
def flatten_mapping(self, node):
        # type: (Any) -> Any
        """
        This implements the merge key feature http://yaml.org/type/merge.html
        by inserting keys from the merge dict/list of dicts if not yet
        available in this node
        """
        merge = []  # type: List[Any]
        index = 0
        while index < len(node.value):
            key_node, value_node = node.value[index]
            if key_node.tag == u"tag:yaml.org,2002:merge":
                if merge:  # double << key
                    if self.allow_duplicate_keys:
                        del node.value[index]
                        index += 1
                        continue
                    args = [
                        "while constructing a mapping",
                        node.start_mark,
                        'found duplicate key "{}"'.format(key_node.value),
                        key_node.start_mark,
                        """
                        To suppress this check see:
                           http://yaml.readthedocs.io/en/latest/api.html#duplicate-keys
                        """,
                        """\
                        Duplicate keys will become an error in future releases, and are errors
                        by default when using the new API.
                        """,
                    ]
                    if self.allow_duplicate_keys is None:
                        warnings.warn(DuplicateKeyFutureWarning(*args))
                    else:
                        raise DuplicateKeyError(*args)
                del node.value[index]
                if isinstance(value_node, MappingNode):
                    self.flatten_mapping(value_node)
                    merge.extend(value_node.value)
                elif isinstance(value_node, SequenceNode):
                    submerge = []
                    for subnode in value_node.value:
                        if not isinstance(subnode, MappingNode):
                            raise ConstructorError(
                                "while constructing a mapping",
                                node.start_mark,
                                "expected a mapping for merging, but found %s"
                                % subnode.id,
                                subnode.start_mark,
                            )
                        self.flatten_mapping(subnode)
                        submerge.append(subnode.value)
                    submerge.reverse()
                    for value in submerge:
                        merge.extend(value)
                else:
                    raise ConstructorError(
                        "while constructing a mapping",
                        node.start_mark,
                        "expected a mapping or list of mappings for merging, "
                        "but found %s" % value_node.id,
                        value_node.start_mark,
                    )
            elif key_node.tag == u"tag:yaml.org,2002:value":
                key_node.tag = u"tag:yaml.org,2002:str"
                index += 1
            else:
                index += 1
        if bool(merge):
            node.merge = (
                merge
            )  # separate merge keys to be able to update without duplicate
            node.value = merge + node.value
def flatten_mapping ( self , node ) : # type: (Any) -> Any merge = [ ] # type: List[Any] index = 0 while index < len ( node . value ) : key_node , value_node = node . value [ index ] if key_node . tag == u"tag:yaml.org,2002:merge" : if merge : # double << key if self . allow_duplicate_keys : del node . value [ index ] index += 1 continue args = [ "while constructing a mapping" , node . start_mark , 'found duplicate key "{}"' . format ( key_node . value ) , key_node . start_mark , """
                        To suppress this check see:
                           http://yaml.readthedocs.io/en/latest/api.html#duplicate-keys
                        """ , """\
                        Duplicate keys will become an error in future releases, and are errors
                        by default when using the new API.
                        """ , ] if self . allow_duplicate_keys is None : warnings . warn ( DuplicateKeyFutureWarning ( * args ) ) else : raise DuplicateKeyError ( * args ) del node . value [ index ] if isinstance ( value_node , MappingNode ) : self . flatten_mapping ( value_node ) merge . extend ( value_node . value ) elif isinstance ( value_node , SequenceNode ) : submerge = [ ] for subnode in value_node . value : if not isinstance ( subnode , MappingNode ) : raise ConstructorError ( "while constructing a mapping" , node . start_mark , "expected a mapping for merging, but found %s" % subnode . id , subnode . start_mark , ) self . flatten_mapping ( subnode ) submerge . append ( subnode . value ) submerge . reverse ( ) for value in submerge : merge . extend ( value ) else : raise ConstructorError ( "while constructing a mapping" , node . start_mark , "expected a mapping or list of mappings for merging, " "but found %s" % value_node . id , value_node . start_mark , ) elif key_node . tag == u"tag:yaml.org,2002:value" : key_node . tag = u"tag:yaml.org,2002:str" index += 1 else : index += 1 if bool ( merge ) : node . merge = ( merge ) # separate merge keys to be able to update without duplicate node . value = merge + node . value