(self, node, deep=False)
return total_mapping
deep is True when creating an object/mapping recursively,
        in that case want the underlying elements available during construction
deep is True when creating an object/mapping recursively,
        in that case want the underlying elements available during construction
deep is True when creating an object / mapping recursively in that case want the underlying elements available during construction
def construct_mapping(self, node, deep=False):
        # type: (Any, bool) -> Any
        """deep is True when creating an object/mapping recursively,
        in that case want the underlying elements available during construction
        """
        if not isinstance(node, MappingNode):
            raise ConstructorError(
                None,
                None,
                "expected a mapping node, but found %s" % node.id,
                node.start_mark,
            )
        total_mapping = self.yaml_base_dict_type()
        if getattr(node, "merge", None) is not None:
            todo = [(node.merge, False), (node.value, False)]
        else:
            todo = [(node.value, True)]
        for values, check in todo:
            mapping = self.yaml_base_dict_type()  # type: Dict[Any, Any]
            for key_node, value_node in values:
                # keys can be list -> deep
                key = self.construct_object(key_node, deep=True)
                # lists are not hashable, but tuples are
                if not isinstance(key, Hashable):
                    if isinstance(key, list):
                        key = tuple(key)
                if PY2:
                    try:
                        hash(key)
                    except TypeError as exc:
                        raise ConstructorError(
                            "while constructing a mapping",
                            node.start_mark,
                            "found unacceptable key (%s)" % exc,
                            key_node.start_mark,
                        )
                else:
                    if not isinstance(key, Hashable):
                        raise ConstructorError(
                            "while constructing a mapping",
                            node.start_mark,
                            "found unhashable key",
                            key_node.start_mark,
                        )

                value = self.construct_object(value_node, deep=deep)
                if check:
                    if self.check_mapping_key(node, key_node, mapping, key, value):
                        mapping[key] = value
                else:
                    mapping[key] = value
            total_mapping.update(mapping)
        return total_mapping
def construct_mapping ( self , node , deep = False ) : # type: (Any, bool) -> Any if not isinstance ( node , MappingNode ) : raise ConstructorError ( None , None , "expected a mapping node, but found %s" % node . id , node . start_mark , ) total_mapping = self . yaml_base_dict_type ( ) if getattr ( node , "merge" , None ) is not None : todo = [ ( node . merge , False ) , ( node . value , False ) ] else : todo = [ ( node . value , True ) ] for values , check in todo : mapping = self . yaml_base_dict_type ( ) # type: Dict[Any, Any] for key_node , value_node in values : # keys can be list -> deep key = self . construct_object ( key_node , deep = True ) # lists are not hashable, but tuples are if not isinstance ( key , Hashable ) : if isinstance ( key , list ) : key = tuple ( key ) if PY2 : try : hash ( key ) except TypeError as exc : raise ConstructorError ( "while constructing a mapping" , node . start_mark , "found unacceptable key (%s)" % exc , key_node . start_mark , ) else : if not isinstance ( key , Hashable ) : raise ConstructorError ( "while constructing a mapping" , node . start_mark , "found unhashable key" , key_node . start_mark , ) value = self . construct_object ( value_node , deep = deep ) if check : if self . check_mapping_key ( node , key_node , mapping , key , value ) : mapping [ key ] = value else : mapping [ key ] = value total_mapping . update ( mapping ) return total_mapping