Exemplo n.º 1
0
    def construct_yaml_map(self, node):
        """
        Return a node class representing a line-marked dictionary.

        """
        obj, = SafeConstructor.construct_yaml_map(self, node)
        return DictNode(obj, node.start_mark, node.end_mark)
Exemplo n.º 2
0
    def construct_yaml_map(self, node):

        # Check for duplicate keys on the current level, this is not desirable
        # because a dict does not support this. It overwrites it with the last
        # occurance, which can give unexpected results
        mapping = {}
        self.flatten_mapping(node)
        for key_node, value_node in node.value:
            key = self.construct_object(key_node, False)
            value = self.construct_object(value_node, False)

            if key in mapping:
                raise CfnParseError(self.filename, [
                    build_match(
                        filename=self.filename,
                        message='Duplicate resource found "{}" (line {})'.
                        format(key, key_node.start_mark.line + 1),
                        line_number=key_node.start_mark.line,
                        column_number=key_node.start_mark.column,
                        key=key),
                    build_match(
                        filename=self.filename,
                        message='Duplicate resource found "{}" (line {})'.
                        format(key, mapping[key].start_mark.line + 1),
                        line_number=mapping[key].start_mark.line,
                        column_number=mapping[key].start_mark.column,
                        key=key)
                ])
            mapping[key] = value

        obj, = SafeConstructor.construct_yaml_map(self, node)
        return dict_node(obj, node.start_mark, node.end_mark)
Exemplo n.º 3
0
    def construct_yaml_map(self, node):
        """
        Return a node class representing a line-marked dictionary.

        """
        obj, = SafeConstructor.construct_yaml_map(self, node)
        return DictNode(obj, node.start_mark, node.end_mark)
Exemplo n.º 4
0
    def construct_yaml_map(self, node):

        # Check for duplicate keys on the current level, this is not desirable
        # because a dict does not support this. It overwrites it with the last
        # occurance, which can give unexpected results
        mapping = {}
        for key_node, value_node in node.value:
            key = self.construct_object(key_node, False)
            value = self.construct_object(value_node, False)

            if key in mapping:
                raise DuplicateError('"{}" (line {})'.format(
                    key, key_node.start_mark.line + 1))
            mapping[key] = value

        obj, = SafeConstructor.construct_yaml_map(self, node)
        return dict_node(obj, node.start_mark, node.end_mark)
Exemplo n.º 5
0
 def construct_yaml_map(self, node):
     obj, = SafeConstructor.construct_yaml_map(self, node)
     return dict_node(obj, node.start_mark, node.end_mark)
Exemplo n.º 6
0
 def construct_yaml_map(self, node):
     (obj, ) = SafeConstructor.construct_yaml_map(self, node)
     return dict_node(obj, node.start_mark, node.end_mark)
 def construct_yaml_map(self, node):
     obj, = SafeConstructor.construct_yaml_map(self, node)
     return self._holder(obj, node)
Exemplo n.º 8
0
 def construct_yaml_map(self, node):
     obj, = SafeConstructor.construct_yaml_map(self, node)
     return dict_node(obj, node_info=node)
Exemplo n.º 9
0
 def construct_yaml_map(self, node):
     obj, = SafeConstructor.construct_yaml_map(self, node)
     return self._holder(obj, node)