示例#1
0
    def compare(self, other, progress_bar):
        '''
        :type other: cts_core.metadata.metadata_container.TypesContainer
        :return: cts_core.metadata.compare_result.CompareResult
        '''

        cmp = Comparator(level=0)

        types = set(self.keys())
        types_other = set(other.keys())
        all = sorted(list(types.union(types_other)))
        both = types.intersection(types_other)

        fmt = "Type: {type}"
        for type in all:
            if progress_bar is not None:
                progress_bar.set_label(type)

            if type in both:
                cmp.merge_result(self.__getitem__(type).compare(other.__getitem__(type)))
            elif type in types:
                cmp.set_not_equal()
                cmp.message_left(fmt.format(type=type))
                cmp.message_right('?')
                cmp.separator()
            else:
                cmp.set_not_equal()
                cmp.message_left('?')
                cmp.message_right(fmt.format(type=type))
                cmp.separator()

            if progress_bar is not None:
                progress_bar.make_progress()
        return cmp
示例#2
0
    def compare(self, other, progress_bar):
        '''
        :type other: cts_core.metadata.metadata_container.EntitiesContainer
        :return: int
        '''
        cmp = Comparator(level=0)

        entities = set(self.keys())
        entities_other = set(other.keys())
        all = sorted(list(entities.union(entities_other)))
        both = entities.intersection(entities_other)

        fmt = "Entity: {entity}"
        for entity in all:
            if progress_bar is not None:
                progress_bar.set_label(entity)

            if entity in both:
                cmp.merge_result(self.__getitem__(entity).compare(other.__getitem__(entity)))
            elif entity in entities:
                cmp.set_not_equal()
                cmp.message_left(fmt.format(entity=entity))
                cmp.message_right('?')
                cmp.separator()
            else:
                cmp.set_not_equal()
                cmp.message_left('?')
                cmp.message_right(fmt.format(entity=entity))
                cmp.separator()

            if progress_bar is not None:
                progress_bar.make_progress()
        return cmp
示例#3
0
    def compare(self, other, progress_bar):
        '''
        :type other: cts_core.metadata.metadata_container.EntitiesContainer
        :return: int
        '''
        cmp = Comparator(level=0)

        entities = set(self.keys())
        entities_other = set(other.keys())
        all = sorted(list(entities.union(entities_other)))
        both = entities.intersection(entities_other)

        fmt = "Entity: {entity}"
        for entity in all:
            if progress_bar is not None:
                progress_bar.set_label(entity)

            if entity in both:
                cmp.merge_result(
                    self.__getitem__(entity).compare(
                        other.__getitem__(entity)))
            elif entity in entities:
                cmp.set_not_equal()
                cmp.message_left(fmt.format(entity=entity))
                cmp.message_right('?')
                cmp.separator()
            else:
                cmp.set_not_equal()
                cmp.message_left('?')
                cmp.message_right(fmt.format(entity=entity))
                cmp.separator()

            if progress_bar is not None:
                progress_bar.make_progress()
        return cmp
示例#4
0
    def compare_properties(self, other, level):
        """
        :type other: cts_core.metadata.model.metadata_model.MetadataModel
        :rtype: int
        """
        cmp = Comparator(level)

        properties = set(self.properties.keys())
        properties_other = set(other.properties.keys())
        all = sorted(list(properties.union(properties_other)))
        both = properties.intersection(properties_other)
        fmt = "Property: {name}"

        for property in all:
            if property in both:
                cmp.merge_result(self.properties[property].compare(other.properties[property], level))
            elif property in properties:
                cmp.set_not_equal()
                cmp.message_left(fmt.format(name=property))
                cmp.message_right('?')
            else:
                cmp.set_not_equal()
                cmp.message_left('?')
                cmp.message_right(fmt.format(name=property))
        return cmp
示例#5
0
    def compare(self, other, progress_bar):
        '''
        :type other: cts_core.metadata.metadata_container.TypesContainer
        :return: cts_core.metadata.compare_result.CompareResult
        '''

        cmp = Comparator(level=0)

        types = set(self.keys())
        types_other = set(other.keys())
        all = sorted(list(types.union(types_other)))
        both = types.intersection(types_other)

        fmt = "Type: {type}"
        for type in all:
            if progress_bar is not None:
                progress_bar.set_label(type)

            if type in both:
                cmp.merge_result(
                    self.__getitem__(type).compare(other.__getitem__(type)))
            elif type in types:
                cmp.set_not_equal()
                cmp.message_left(fmt.format(type=type))
                cmp.message_right('?')
                cmp.separator()
            else:
                cmp.set_not_equal()
                cmp.message_left('?')
                cmp.message_right(fmt.format(type=type))
                cmp.separator()

            if progress_bar is not None:
                progress_bar.make_progress()
        return cmp
示例#6
0
    def compare_annotations(self, other, level):
        """
        :type other: cts_core.metadata.model.metadata_model.MetadataModel
        :rtype: int
        """
        cmp = Comparator(level)

        annotations = set(self.annotations.keys())
        annotations_other = set(other.annotations.keys())
        all = sorted(list(annotations.union(annotations_other)))
        both = annotations.intersection(annotations_other)

        fmt = "Annotation: {name}"
        for annotation in all:
            if annotation in both:
                cmp.merge_result(self.annotations[annotation].compare(other.annotations[annotation], level))
            elif annotation in annotations:
                cmp.set_not_equal()
                cmp.message_left(fmt.format(name=annotation))
                cmp.message_right('?')
            else:
                cmp.set_not_equal()
                cmp.message_left('?')
                cmp.message_right(fmt.format(name=annotation))

        return cmp
示例#7
0
    def compare_patch_status(self, other, level):
        """
        :type other: cts_core.metadata.model.property.Property
        :rtype: int
        """
        cmp = Comparator(level)
        if self.patch_status != other.patch_status:
            cmp.message_left(self.patch_status)
            cmp.message_right(other.patch_status)
            cmp.set_not_equal()

        return cmp
示例#8
0
    def compare_nullable(self, other, level):
        """
        :type other: cts_core.metadata.model.property.Property
        :rtype: int
        """
        cmp = Comparator(level)
        if self.nullable != other.nullable:
            cmp.message_left("Nullable" if self.nullable else "Not Nullable")
            cmp.message_right("Nullable" if other.nullable else "Not Nullable")
            cmp.set_not_equal()

        return cmp
示例#9
0
    def compare_is_required(self, other, level):
        """
        :type other: cts_core.metadata.model.property.Property
        :rtype: int
        """

        cmp = Comparator(level)
        if self.is_required != other.is_required:
            cmp.message_left("Required" if self.is_required else "Optional")
            cmp.message_right("Required" if other.is_required else "Optional")
            cmp.set_not_equal()

        return cmp
示例#10
0
    def compare_base_type(self, other, level):
        """
        :type other: cts_core.metadata.model.metadata_model.MetadataModel
        :type cmp: cts_core.metadata.comparator.Comparator
        :rtype: int
        """
        cmp = Comparator(level)
        if self.base_type != other.base_type:
            fmt = "Base type: {base}"
            cmp.message_left(fmt.format(base=self.base_type))
            cmp.message_right(fmt.format(base=other.base_type))
            cmp.set_not_equal()

        return cmp
示例#11
0
    def compare_type(self, other, level):
        """
        :type other: cts_core.metadata.model.property.Property
        :rtype: int
        """
        cmp = Comparator(level)
        if self.type != other.type or self.is_collection != other.is_collection:
            fmt = "Type: {type}"
            fmt_collection = "Type: Collection({type})"
            cmp.message_left(
                (fmt_collection if self.is_collection else fmt).format(
                    type=self.type))
            cmp.message_right(
                (fmt_collection if other.is_collection else fmt).format(
                    type=other.type))
            cmp.set_not_equal()

        return cmp
示例#12
0
    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
示例#13
0
    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