PyFunceble/config.py
def compare(self):
        """
        Compare the current version with the upstream saved version.
        """

        if self.upstream_data["force_update"]["status"]:
            # The force_update status is set to True.

            for minimal in self.upstream_data["force_update"]["minimal_version"]:
                # We loop through the list of minimal version which trigger the
                # the force update message.

                # We compare the local with the currently read minimal version.
                checked = self.check_versions(
                    self.local_splited, self.split_versions(minimal)
                )

                if not PyFunceble.CONFIGURATION["quiet"]:
                    # The quiet mode is not activated.

                    if checked or checked is not False and not checked:
                        # The current version is less or equal to
                        # the minimal version.

                        # We initiate the message we are going to return to
                        # the user.
                        message = (
                            PyFunceble.Style.BRIGHT
                            + PyFunceble.Fore.RED
                            + "A critical issue has been fixed.\n"
                            + PyFunceble.Style.RESET_ALL
                        )  # pylint:disable=line-too-long
                        message += (
                            PyFunceble.Style.BRIGHT
                            + PyFunceble.Fore.GREEN
                            + "Please take the time to update PyFunceble!\n"
                            + PyFunceble.Style.RESET_ALL
                        )  # pylint:disable=line-too-long

                        # We print the message on screen.
                        print(message)

                        # We exit PyFunceble with the code 1.
                        exit(1)
                elif checked or checked is not False and not checked:
                    # The quiet mode is activated and the current version
                    # is less or equal to the minimal version.

                    # We raise an exception telling the user to update their
                    # instance of PyFunceble.
                    raise Exception(
                        "A critical issue has been fixed. Please take the time to update PyFunceble!"  # pylint:disable=line-too-long
                    )

        for version in self.upstream_data["deprecated"]:
            # We loop through the list of deprecated versions.

            # We compare the local with the currently read deprecated version.
            checked = self.check_versions(
                self.local_splited, self.split_versions(version)
            )

            if (
                not PyFunceble.CONFIGURATION["quiet"]
                and checked
                or checked is not False
                and not checked
            ):
                # The quiet mode is not activated and the local version is
                # less or equal to the currently read deprecated version.

                # We initiate the message we are going to return to the user.
                message = (
                    PyFunceble.Style.BRIGHT
                    + PyFunceble.Fore.RED
                    + "Your current version is considered as deprecated.\n"
                    + PyFunceble.Style.RESET_ALL
                )  # pylint:disable=line-too-long
                message += (
                    PyFunceble.Style.BRIGHT
                    + PyFunceble.Fore.GREEN
                    + "Please take the time to update PyFunceble!\n"
                    + PyFunceble.Style.RESET_ALL
                )  # pylint:disable=line-too-long

                # We print the message.
                print(message)

                # And we continue to the next logic. There is no need to
                # shutdown PyFunceble as it's just for information.
                return

            # The quiet mode is activated.

            if checked or checked is not False and not checked:
                # The local version is  less or equal to the currently
                # read deprecated version.
                print("Version deprecated.")

                # And we continue to the next logic. There is no need to
                # shutdown PyFunceble as it's just for information.
                return

        # We compare the local version with the upstream version.
        status = self.check_versions(
            self.local_splited,
            self.split_versions(self.upstream_data["current_version"]),
        )

        if status is not None and not status and not PyFunceble.CONFIGURATION["quiet"]:
            # The quiet mode is not activate and the current version is greater than
            # the upstream version.

            # We initiate the message we are going to return to the user.
            message = (
                PyFunceble.Style.BRIGHT
                + PyFunceble.Fore.CYAN
                + "Your version is more recent!\nYou should really think about sharing your changes with the community!\n"  # pylint:disable=line-too-long
                + PyFunceble.Style.RESET_ALL
            )
            message += (
                PyFunceble.Style.BRIGHT
                + "Your version: "
                + PyFunceble.Style.RESET_ALL
                + PyFunceble.VERSION
                + "\n"
            )
            message += (
                PyFunceble.Style.BRIGHT
                + "Upstream version: "
                + PyFunceble.Style.RESET_ALL
                + self.upstream_data["current_version"]
                + "\n"
            )

            # We print the message.
            print(message)
        elif status:
            # The current version is less that the upstream version.

            if not PyFunceble.CONFIGURATION["quiet"]:
                # The quiet mode is not activated.

                # We initiate the message we are going to return to the user.
                message = (
                    PyFunceble.Style.BRIGHT
                    + PyFunceble.Fore.YELLOW
                    + "Please take the time to update PyFunceble!\n"
                    + PyFunceble.Style.RESET_ALL
                )  # pylint:disable=line-too-long
                message += (
                    PyFunceble.Style.BRIGHT
                    + "Your version: "
                    + PyFunceble.Style.RESET_ALL
                    + PyFunceble.VERSION
                    + "\n"
                )  # pylint:disable=line-too-long
                message += (
                    PyFunceble.Style.BRIGHT
                    + "Upstream version: "
                    + PyFunceble.Style.RESET_ALL
                    + self.upstream_data[  # pylint:disable=line-too-long
                        "current_version"
                    ]
                    + "\n"
                )

                # We print the message.
                print(message)
            else:
                # The quiet mode is activated.

                # We print the message.
                print("New version available.")

        # And we continue to the next app logic. There is no need to
        # shutdown PyFunceble as it's just for information.
        return
def compare(self):
        """
        Compare the current version with the upstream saved version.
        """

        if self.upstream_data["force_update"]["status"]:
            # The force_update status is set to True.

            for minimal in self.upstream_data["force_update"]["minimal_version"]:
                # We loop through the list of minimal version which trigger the
                # the force update message.

                # We compare the local with the currently read minimal version.
                checked = self.check_versions(
                    self.local_splited, self.split_versions(minimal)
                )

                if not PyFunceble.CONFIGURATION["quiet"]:
                    # The quiet mode is not activated.

                    if checked or checked is not False and not checked:
                        # The current version is less or equal to
                        # the minimal version.

                        # We initiate the message we are going to return to
                        # the user.
                        message = (
                            PyFunceble.Style.BRIGHT
                            + PyFunceble.Fore.RED
                            + "A critical issue has been fixed.\n"
                            + PyFunceble.Style.RESET_ALL
                        )  # pylint:disable=line-too-long
                        message += (
                            PyFunceble.Style.BRIGHT
                            + PyFunceble.Fore.GREEN
                            + "Please take the time to update PyFunceble!\n"
                            + PyFunceble.Style.RESET_ALL
                        )  # pylint:disable=line-too-long

                        # We print the message on screen.
                        print(message)

                        # We exit PyFunceble with the code 1.
                        exit(1)
                elif checked or checked is not False and not checked:
                    # The quiet mode is activated and the current version
                    # is less or equal to the minimal version.

                    # We raise an exception telling the user to update their
                    # instance of PyFunceble.
                    raise Exception(
                        "A critical issue has been fixed. Please take the time to update PyFunceble!"  # pylint:disable=line-too-long
                    )

        for version in self.upstream_data["deprecated"]:
            # We loop through the list of deprecated versions.

            # We compare the local with the currently read deprecated version.
            checked = self.check_versions(
                self.local_splited, self.split_versions(version)
            )

            if (
                not PyFunceble.CONFIGURATION["quiet"]
                and checked
                or checked is not False
                and not checked
            ):
                # The quiet mode is not activated and the local version is
                # less or equal to the currently read deprecated version.

                # We initiate the message we are going to return to the user.
                message = (
                    PyFunceble.Style.BRIGHT
                    + PyFunceble.Fore.RED
                    + "Your current version is considered as deprecated.\n"
                    + PyFunceble.Style.RESET_ALL
                )  # pylint:disable=line-too-long
                message += (
                    PyFunceble.Style.BRIGHT
                    + PyFunceble.Fore.GREEN
                    + "Please take the time to update PyFunceble!\n"
                    + PyFunceble.Style.RESET_ALL
                )  # pylint:disable=line-too-long

                # We print the message.
                print(message)

                # And we continue to the next logic. There is no need to
                # shutdown PyFunceble as it's just for information.
                return

            # The quiet mode is activated.

            if checked or checked is not False and not checked:
                # The local version is  less or equal to the currently
                # read deprecated version.
                print("Version deprecated.")

                # And we continue to the next logic. There is no need to
                # shutdown PyFunceble as it's just for information.
                return

        # We compare the local version with the upstream version.
        status = self.check_versions(
            self.local_splited,
            self.split_versions(self.upstream_data["current_version"]),
        )

        if status is not None and not status and not PyFunceble.CONFIGURATION["quiet"]:
            # The quiet mode is not activate and the current version is greater than
            # the upstream version.

            # We initiate the message we are going to return to the user.
            message = (
                PyFunceble.Style.BRIGHT
                + PyFunceble.Fore.CYAN
                + "Your version is more recent!\nYou should really think about sharing your changes with the community!\n"  # pylint:disable=line-too-long
                + PyFunceble.Style.RESET_ALL
            )
            message += (
                PyFunceble.Style.BRIGHT
                + "Your version: "
                + PyFunceble.Style.RESET_ALL
                + PyFunceble.VERSION
                + "\n"
            )
            message += (
                PyFunceble.Style.BRIGHT
                + "Upstream version: "
                + PyFunceble.Style.RESET_ALL
                + self.upstream_data["current_version"]
                + "\n"
            )

            # We print the message.
            print(message)
        elif status:
            # The current version is less that the upstream version.

            if not PyFunceble.CONFIGURATION["quiet"]:
                # The quiet mode is not activated.

                # We initiate the message we are going to return to the user.
                message = (
                    PyFunceble.Style.BRIGHT
                    + PyFunceble.Fore.YELLOW
                    + "Please take the time to update PyFunceble!\n"
                    + PyFunceble.Style.RESET_ALL
                )  # pylint:disable=line-too-long
                message += (
                    PyFunceble.Style.BRIGHT
                    + "Your version: "
                    + PyFunceble.Style.RESET_ALL
                    + PyFunceble.VERSION
                    + "\n"
                )  # pylint:disable=line-too-long
                message += (
                    PyFunceble.Style.BRIGHT
                    + "Upstream version: "
                    + PyFunceble.Style.RESET_ALL
                    + self.upstream_data[  # pylint:disable=line-too-long
                        "current_version"
                    ]
                    + "\n"
                )

                # We print the message.
                print(message)
            else:
                # The quiet mode is activated.

                # We print the message.
                print("New version available.")

        # And we continue to the next app logic. There is no need to
        # shutdown PyFunceble as it's just for information.
        return
def compare ( self ) : if self . upstream_data [ "force_update" ] [ "status" ] : # The force_update status is set to True. for minimal in self . upstream_data [ "force_update" ] [ "minimal_version" ] : # We loop through the list of minimal version which trigger the # the force update message. # We compare the local with the currently read minimal version. checked = self . check_versions ( self . local_splited , self . split_versions ( minimal ) ) if not PyFunceble . CONFIGURATION [ "quiet" ] : # The quiet mode is not activated. if checked or checked is not False and not checked : # The current version is less or equal to # the minimal version. # We initiate the message we are going to return to # the user. message = ( PyFunceble . Style . BRIGHT + PyFunceble . Fore . RED + "A critical issue has been fixed.\n" + PyFunceble . Style . RESET_ALL ) # pylint:disable=line-too-long message += ( PyFunceble . Style . BRIGHT + PyFunceble . Fore . GREEN + "Please take the time to update PyFunceble!\n" + PyFunceble . Style . RESET_ALL ) # pylint:disable=line-too-long # We print the message on screen. print ( message ) # We exit PyFunceble with the code 1. exit ( 1 ) elif checked or checked is not False and not checked : # The quiet mode is activated and the current version # is less or equal to the minimal version. # We raise an exception telling the user to update their # instance of PyFunceble. raise Exception ( "A critical issue has been fixed. Please take the time to update PyFunceble!" # pylint:disable=line-too-long ) for version in self . upstream_data [ "deprecated" ] : # We loop through the list of deprecated versions. # We compare the local with the currently read deprecated version. checked = self . check_versions ( self . local_splited , self . split_versions ( version ) ) if ( not PyFunceble . CONFIGURATION [ "quiet" ] and checked or checked is not False and not checked ) : # The quiet mode is not activated and the local version is # less or equal to the currently read deprecated version. # We initiate the message we are going to return to the user. message = ( PyFunceble . Style . BRIGHT + PyFunceble . Fore . RED + "Your current version is considered as deprecated.\n" + PyFunceble . Style . RESET_ALL ) # pylint:disable=line-too-long message += ( PyFunceble . Style . BRIGHT + PyFunceble . Fore . GREEN + "Please take the time to update PyFunceble!\n" + PyFunceble . Style . RESET_ALL ) # pylint:disable=line-too-long # We print the message. print ( message ) # And we continue to the next logic. There is no need to # shutdown PyFunceble as it's just for information. return # The quiet mode is activated. if checked or checked is not False and not checked : # The local version is  less or equal to the currently # read deprecated version. print ( "Version deprecated." ) # And we continue to the next logic. There is no need to # shutdown PyFunceble as it's just for information. return # We compare the local version with the upstream version. status = self . check_versions ( self . local_splited , self . split_versions ( self . upstream_data [ "current_version" ] ) , ) if status is not None and not status and not PyFunceble . CONFIGURATION [ "quiet" ] : # The quiet mode is not activate and the current version is greater than # the upstream version. # We initiate the message we are going to return to the user. message = ( PyFunceble . Style . BRIGHT + PyFunceble . Fore . CYAN + "Your version is more recent!\nYou should really think about sharing your changes with the community!\n" # pylint:disable=line-too-long + PyFunceble . Style . RESET_ALL ) message += ( PyFunceble . Style . BRIGHT + "Your version: " + PyFunceble . Style . RESET_ALL + PyFunceble . VERSION + "\n" ) message += ( PyFunceble . Style . BRIGHT + "Upstream version: " + PyFunceble . Style . RESET_ALL + self . upstream_data [ "current_version" ] + "\n" ) # We print the message. print ( message ) elif status : # The current version is less that the upstream version. if not PyFunceble . CONFIGURATION [ "quiet" ] : # The quiet mode is not activated. # We initiate the message we are going to return to the user. message = ( PyFunceble . Style . BRIGHT + PyFunceble . Fore . YELLOW + "Please take the time to update PyFunceble!\n" + PyFunceble . Style . RESET_ALL ) # pylint:disable=line-too-long message += ( PyFunceble . Style . BRIGHT + "Your version: " + PyFunceble . Style . RESET_ALL + PyFunceble . VERSION + "\n" ) # pylint:disable=line-too-long message += ( PyFunceble . Style . BRIGHT + "Upstream version: " + PyFunceble . Style . RESET_ALL + self . upstream_data [ # pylint:disable=line-too-long "current_version" ] + "\n" ) # We print the message. print ( message ) else : # The quiet mode is activated. # We print the message. print ( "New version available." ) # And we continue to the next app logic. There is no need to # shutdown PyFunceble as it's just for information. return
Compare the current version with the upstream saved version.
Compare the current version with the upstream saved version .