(self, node, key_node, mapping, key, value)
return True
return True if key is unique
return True if key is unique
return True if key is unique
def check_mapping_key(self, node, key_node, mapping, key, value):
        # type: (Any, Any, Any, Any, Any) -> bool
        """return True if key is unique"""
        if key in mapping:
            if not self.allow_duplicate_keys:
                mk = mapping.get(key)
                if PY2:
                    if isinstance(key, unicode):
                        key = key.encode("utf-8")
                    if isinstance(value, unicode):
                        value = value.encode("utf-8")
                    if isinstance(mk, unicode):
                        mk = mk.encode("utf-8")
                args = [
                    "while constructing a mapping",
                    node.start_mark,
                    'found duplicate key "{}" with value "{}" '
                    '(original value: "{}")'.format(key, value, mk),
                    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)
            return False
        return True
def check_mapping_key ( self , node , key_node , mapping , key , value ) : # type: (Any, Any, Any, Any, Any) -> bool if key in mapping : if not self . allow_duplicate_keys : mk = mapping . get ( key ) if PY2 : if isinstance ( key , unicode ) : key = key . encode ( "utf-8" ) if isinstance ( value , unicode ) : value = value . encode ( "utf-8" ) if isinstance ( mk , unicode ) : mk = mk . encode ( "utf-8" ) args = [ "while constructing a mapping" , node . start_mark , 'found duplicate key "{}" with value "{}" ' '(original value: "{}")' . format ( key , value , mk ) , 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 ) return False return True