| 95 | | value_node = node.value[key_node] |
| 96 | | if isinstance(value_node, MappingNode): |
| 97 | | merge = [self.construct_mapping(value_node)] |
| 98 | | elif isinstance(value_node, SequenceNode): |
| 99 | | merge = [] |
| 100 | | for subnode in value_node.value: |
| 101 | | if not isinstance(subnode, MappingNode): |
| 102 | | raise ConstructorError("while constructing a mapping", |
| 103 | | node.start_marker, |
| 104 | | "expected a mapping for merging, but found %s" |
| 105 | | % subnode.id, subnode.start_marker) |
| 106 | | merge.append(self.construct_mapping(subnode)) |
| 107 | | merge.reverse() |
| 108 | | else: |
| 109 | | raise ConstructorError("while constructing a mapping", node.start_marker, |
| 110 | | "expected a mapping or list of mappings for merging, but found %s" |
| 111 | | % value_node.id, value_node.start_marker) |
| | 95 | value_node = node.value[key_node] |
| | 96 | if isinstance(value_node, MappingNode): |
| | 97 | merge = [self.construct_mapping(value_node)] |
| | 98 | elif isinstance(value_node, SequenceNode): |
| | 99 | merge = [] |
| | 100 | for subnode in value_node.value: |
| | 101 | if not isinstance(subnode, MappingNode): |
| | 102 | raise ConstructorError("while constructing a mapping", |
| | 103 | node.start_marker, |
| | 104 | "expected a mapping for merging, but found %s" |
| | 105 | % subnode.id, subnode.start_marker) |
| | 106 | merge.append(self.construct_mapping(subnode)) |
| | 107 | merge.reverse() |
| | 108 | else: |
| | 109 | raise ConstructorError("while constructing a mapping", node.start_marker, |
| | 110 | "expected a mapping or list of mappings for merging, but found %s" |
| | 111 | % value_node.id, value_node.start_marker) |
| 284 | | if len(subnode.value) != 1: |
| 285 | | raise ConstructorError("while constructing an ordered map", node.start_marker, |
| 286 | | "expected a single mapping item, but found %d items" % len(subnode.value), |
| 287 | | subnode.start_marker) |
| 288 | | key_node = subnode.value.keys()[0] |
| 289 | | key = self.construct_object(key_node) |
| 290 | | value = self.construct_object(subnode.value[key_node]) |
| 291 | | omap.append((key, value)) |
| | 284 | if len(subnode.value) != 1: |
| | 285 | raise ConstructorError("while constructing an ordered map", node.start_marker, |
| | 286 | "expected a single mapping item, but found %d items" % len(subnode.value), |
| | 287 | subnode.start_marker) |
| | 288 | key_node = subnode.value.keys()[0] |
| | 289 | key = self.construct_object(key_node) |
| | 290 | value = self.construct_object(subnode.value[key_node]) |
| | 291 | omap.append((key, value)) |
| | 292 | return omap |
| 304 | | if len(subnode.value) != 1: |
| 305 | | raise ConstructorError("while constructing pairs", node.start_marker, |
| 306 | | "expected a single mapping item, but found %d items" % len(subnode.value), |
| 307 | | subnode.start_marker) |
| 308 | | key_node = subnode.value.keys()[0] |
| 309 | | key = self.construct_object(key_node) |
| 310 | | value = self.construct_object(subnode.value[key_node]) |
| 311 | | omap.append((key, value)) |
| | 305 | if len(subnode.value) != 1: |
| | 306 | raise ConstructorError("while constructing pairs", node.start_marker, |
| | 307 | "expected a single mapping item, but found %d items" % len(subnode.value), |
| | 308 | subnode.start_marker) |
| | 309 | key_node = subnode.value.keys()[0] |
| | 310 | key = self.construct_object(key_node) |
| | 311 | value = self.construct_object(subnode.value[key_node]) |
| | 312 | pairs.append((key, value)) |
| | 313 | return pairs |
| 352 | | u'tag:yaml.org,2002:timestamp', |
| 353 | | Constructor.construct_yaml_timestamp) |
| | 354 | u'tag:yaml.org,2002:binary', |
| | 355 | Constructor.construct_yaml_binary) |
| | 356 | |
| | 357 | if datetime_available: |
| | 358 | Constructor.add_constructor( |
| | 359 | u'tag:yaml.org,2002:timestamp', |
| | 360 | Constructor.construct_yaml_timestamp) |