def class_node_dup_key(): # A Node wrapping a yaml.SequenceNode representing a sequence of # mappings with a duplicate key. tag1 = 'tag:yaml.org,2002:map' item1_key1_node = yaml.ScalarNode('tag:yaml.org,2002:str', 'item_id') item1_value1_node = yaml.ScalarNode('tag:yaml.org,2002:str', 'item') value1 = [(item1_key1_node, item1_value1_node)] item1 = yaml.MappingNode(tag1, value1) tag2 = 'tag:yaml.org,2002:map' item2_key1_node = yaml.ScalarNode('tag:yaml.org,2002:str', 'item_id') item2_value1_node = yaml.ScalarNode('tag:yaml.org,2002:str', 'item') value2 = [(item2_key1_node, item2_value1_node)] item2 = yaml.MappingNode(tag2, value2) seq_node = yaml.SequenceNode('tag:yaml.org,2002:seq', [item1, item2]) list1_key_node = yaml.ScalarNode('tag:yaml.org,2002:str', 'dup_list') value = [(list1_key_node, seq_node)] map_node = yaml.MappingNode('tag:yaml.org,2002:map', value) return yatiml.Node(map_node)
def class_node(yaml_node): return yatiml.Node(yaml_node)
def scalar_node(): ynode = yaml.ScalarNode('tag:yaml.org,2002:int', '42') return yatiml.Node(ynode)
def class_node(yaml_node: yaml.Node) -> yatiml.Node: return yatiml.Node(yaml_node)