PyFunceble/percentage.py
def log(self):
        """
        Print on screen and on file the percentages for each status.
        """

        if (
            PyFunceble.CONFIGURATION["show_percentage"]
            and PyFunceble.INTERN["counter"]["number"]["tested"] > 0
        ):
            # * We are allowed to show the percentage on screen.
            # and
            # * The number of tested is greater than 0.

            # We initiate the output file.
            output = (
                PyFunceble.OUTPUT_DIRECTORY
                + PyFunceble.OUTPUTS["parent_directory"]
                + PyFunceble.OUTPUTS["logs"]["directories"]["parent"]
                + PyFunceble.OUTPUTS["logs"]["directories"]["percentage"]
                + PyFunceble.OUTPUTS["logs"]["filenames"]["percentage"]
            )

            # We delete the output file if it does exist.
            File(output).delete()

            # We calculate the percentage of each statuses.
            self._calculate()

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

                # We print a new line.
                print("\n")

                # We print the percentage header on file and screen.
                Prints(None, "Percentage", output).header()

                # We construct the different lines/data to print on screen and file.
                lines_to_print = [
                    [
                        PyFunceble.STATUS["official"]["up"],
                        str(PyFunceble.INTERN["counter"]["percentage"]["up"]) + "%",
                        PyFunceble.INTERN["counter"]["number"]["up"],
                    ],
                    [
                        PyFunceble.STATUS["official"]["down"],
                        str(PyFunceble.INTERN["counter"]["percentage"]["down"]) + "%",
                        PyFunceble.INTERN["counter"]["number"]["down"],
                    ],
                    [
                        PyFunceble.STATUS["official"]["invalid"],
                        str(PyFunceble.INTERN["counter"]["percentage"]["invalid"])
                        + "%",
                        PyFunceble.INTERN["counter"]["number"]["invalid"],
                    ],
                ]

                if PyFunceble.CONFIGURATION["syntax"]:
                    # We are checking for syntax.

                    # We update the denomination of the UP.
                    lines_to_print[0][0] = PyFunceble.STATUS["official"]["valid"]

                    # And we unset the INACTIVE line.
                    del lines_to_print[1]

                for to_print in lines_to_print:
                    # We loop throught the different line to print.
                    # (one line for each status.)

                    # And we print the current status line on file and screen.
                    Prints(to_print, "Percentage", output).data()

        elif PyFunceble.INTERN["counter"]["number"]["tested"] > 0:
            # * We are not allowed to show the percentage on screen.
            # but
            # * The number of tested is greater than 0.

            # We run the calculation.
            # Note: The following is needed, because all counter calculation are
            # done by this class.
            self._calculate()
def log(self):
        """
        Print on screen and on file the percentages for each status.
        """

        if (
            PyFunceble.CONFIGURATION["show_percentage"]
            and PyFunceble.INTERN["counter"]["number"]["tested"] > 0
        ):
            # * We are allowed to show the percentage on screen.
            # and
            # * The number of tested is greater than 0.

            # We initiate the output file.
            output = (
                PyFunceble.OUTPUT_DIRECTORY
                + PyFunceble.OUTPUTS["parent_directory"]
                + PyFunceble.OUTPUTS["logs"]["directories"]["parent"]
                + PyFunceble.OUTPUTS["logs"]["directories"]["percentage"]
                + PyFunceble.OUTPUTS["logs"]["filenames"]["percentage"]
            )

            # We delete the output file if it does exist.
            File(output).delete()

            # We calculate the percentage of each statuses.
            self._calculate()

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

                # We print a new line.
                print("\n")

                # We print the percentage header on file and screen.
                Prints(None, "Percentage", output).header()

                # We construct the different lines/data to print on screen and file.
                lines_to_print = [
                    [
                        PyFunceble.STATUS["official"]["up"],
                        str(PyFunceble.INTERN["counter"]["percentage"]["up"]) + "%",
                        PyFunceble.INTERN["counter"]["number"]["up"],
                    ],
                    [
                        PyFunceble.STATUS["official"]["down"],
                        str(PyFunceble.INTERN["counter"]["percentage"]["down"]) + "%",
                        PyFunceble.INTERN["counter"]["number"]["down"],
                    ],
                    [
                        PyFunceble.STATUS["official"]["invalid"],
                        str(PyFunceble.INTERN["counter"]["percentage"]["invalid"])
                        + "%",
                        PyFunceble.INTERN["counter"]["number"]["invalid"],
                    ],
                ]

                if PyFunceble.CONFIGURATION["syntax"]:
                    # We are checking for syntax.

                    # We update the denomination of the UP.
                    lines_to_print[0][0] = PyFunceble.STATUS["official"]["valid"]

                    # And we unset the INACTIVE line.
                    del lines_to_print[1]

                for to_print in lines_to_print:
                    # We loop throught the different line to print.
                    # (one line for each status.)

                    # And we print the current status line on file and screen.
                    Prints(to_print, "Percentage", output).data()

        elif PyFunceble.INTERN["counter"]["number"]["tested"] > 0:
            # * We are not allowed to show the percentage on screen.
            # but
            # * The number of tested is greater than 0.

            # We run the calculation.
            # Note: The following is needed, because all counter calculation are
            # done by this class.
            self._calculate()
Print on screen and on file the percentages for each status.