コード例 #1
0
ファイル: annotation.py プロジェクト: 01org/intelRSD
    def compare(self, other, level):
        """
        :type other: cts_core.metadata.model.annotation.Annotation
        :rtype: int
        """
        cmp = Comparator(level)
        cmp.message_both("Annotation: {name}".format(name=self.term))

        attributes = set(self.annotations_attributes_list.keys())
        attributes_other = set(other.annotations_attributes_list.keys())
        all = sorted(list(attributes.union(attributes_other)))
        both = attributes.intersection(attributes_other)
        fmt = "  {name}={value}"
        for attribute in all:
            if attribute in both:
                if self.annotations_attributes_list[attribute] != other.annotations_attributes_list[attribute]:
                    cmp.set_not_equal()
                    cmp.message_left(fmt.format(name=attribute, value=self.annotations_attributes_list[attribute]))
                    cmp.message_right(fmt.format(name=attribute, value=other.annotations_attributes_list[attribute]))
            elif attribute in attributes:
                cmp.set_not_equal()
                cmp.message_left(fmt.format(name=attribute, value=self.annotations_attributes_list[attribute]))
                cmp.message_right('?')
            else:
                cmp.set_not_equal()
                cmp.message_left('?')
                cmp.message_right(fmt.format(name=attribute, value=other.annotations_attributes_list[attribute]))
        return cmp
コード例 #2
0
ファイル: annotation.py プロジェクト: zhangrb/intelRSD
    def compare(self, other, level):
        """
        :type other: cts_core.metadata.model.annotation.Annotation
        :rtype: int
        """
        cmp = Comparator(level)
        cmp.message_both("Annotation: {name}".format(name=self.term))

        attributes = set(self.annotations_attributes_list.keys())
        attributes_other = set(other.annotations_attributes_list.keys())
        all = sorted(list(attributes.union(attributes_other)))
        both = attributes.intersection(attributes_other)
        fmt = "  {name}={value}"
        for attribute in all:
            if attribute in both:
                if self.annotations_attributes_list[attribute] != other.annotations_attributes_list[attribute]:
                    cmp.set_not_equal()
                    cmp.message_left(fmt.format(name=attribute, value=self.annotations_attributes_list[attribute]))
                    cmp.message_right(fmt.format(name=attribute, value=other.annotations_attributes_list[attribute]))
            elif attribute in attributes:
                cmp.set_not_equal()
                cmp.message_left(fmt.format(name=attribute, value=self.annotations_attributes_list[attribute]))
                cmp.message_right('?')
            else:
                cmp.set_not_equal()
                cmp.message_left('?')
                cmp.message_right(fmt.format(name=attribute, value=other.annotations_attributes_list[attribute]))
        return cmp
コード例 #3
0
ファイル: property.py プロジェクト: zhangrb/intelRSD
 def compare(self, other, level):
     """
     :type other: cts_core.metadata.model.property.Property
     :rtype: int
     """
     cmp = Comparator(level)
     cmp.message_both("Property: {name}".format(name=self.name))
     return cmp.merge_result(self.compare_type(other, level + 1),
                             self.compare_nullable(other, level + 1),
                             self.compare_is_required(other, level + 1),
                             self.compare_patch_status(other, level + 1),
                             self.compare_annotations(other, level + 1))
コード例 #4
0
 def compare(self, other):
     """
     :type other: cts_core.metadata.model.metadata_types.complex_type.ComplexType
     :rtype: int
     """
     cmp = Comparator()
     cmp.message_both("Type: {type}".format(type=self.name))
     cmp.merge_result(
         self.compare_base_type(other, level=1),
         self.compare_properties(other, level=1),
         self.compare_annotations(other, level=1),
         self.compare_dynamic_property_patterns(other, level=1))
     cmp.separator()
     return cmp
コード例 #5
0
 def compare(self, other):
     """
     :type other: cts_core.metadata.model.entity.Entity
     :rtype: int
     """
     cmp = Comparator(level=0)
     cmp.message_both("Entity: {entity}".format(entity=self.name))
     cmp.merge_result(
         self.compare_base_type(other, level=1),
         self.compare_properties(other, level=1),
         self.compare_annotations(other, level=1),
         self.compare_dynamic_property_patterns(other, level=1))
     cmp.separator()
     return cmp
コード例 #6
0
ファイル: entity.py プロジェクト: 01org/intelRSD
 def compare(self, other):
     """
     :type other: cts_core.metadata.model.entity.Entity
     :rtype: int
     """
     cmp = Comparator(level=0)
     cmp.message_both("Entity: {entity}".format(entity=self.name))
     cmp.merge_result(
         self.compare_base_type(other, level=1),
         self.compare_properties(other, level=1),
         self.compare_annotations(other, level=1),
         self.compare_dynamic_property_patterns(other, level=1))
     cmp.separator()
     return cmp