PyFunceble/prints.py
def header(
        self, do_not_print=False
    ):  # pragma: no cover pylint: disable=too-many-branches
        """
        Management and creation of templates of header.
        Please consider as "header" the title of each columns.

        :param do_not_print:
            Tell us if we have to print the header or not.
        :type do_not_print: bool
        """

        if (
            not PyFunceble.CONFIGURATION["header_printed"]
            or self.template == "Percentage"
            or do_not_print
        ):
            # * The header has not been already printed.
            # or
            # * The template is the `Percentage template`.
            # or
            # * We are authorized to print something.

            if (
                self.template.lower() in PyFunceble.STATUS["list"]["generic"]
                or self.template == "Generic_File"
            ):
                # * The template is into the list of generic status.
                # or
                # * The template is equal to `Generic_File`.

                # The data to print is the Generic header.
                to_print = self.headers["Generic"]

                if (
                    self.template.lower() in PyFunceble.STATUS["list"]["generic"]
                    and PyFunceble.HTTP_CODE["active"]
                ):
                    # * The template is in the list of generic status.
                    # and
                    # * the http status code extraction is activated.

                    # We remove the Analyze Date colomn from the data to print.
                    to_print = Dict(to_print).remove_key("Analyze Date")
            elif self.template.lower() in PyFunceble.STATUS["list"]["up"]:
                # The template is in the list of up status.

                # We informations to print is the up header.
                to_print = self.headers[PyFunceble.STATUS["official"]["up"]]
            elif self.template.lower() in PyFunceble.STATUS["list"]["valid"]:
                # The template is in the list of valid status.

                # We informations to print is the valid header.
                to_print = self.headers[PyFunceble.STATUS["official"]["valid"]]
            elif self.template.lower() in PyFunceble.STATUS["list"]["down"]:
                # The template is in the list of down status.

                # We informations to print is the down header.
                to_print = self.headers[PyFunceble.STATUS["official"]["down"]]
            elif self.template.lower() in PyFunceble.STATUS["list"]["invalid"]:
                # The template is in the list of invalid status.

                # We informations to print is the invalid header.
                to_print = self.headers[PyFunceble.STATUS["official"]["invalid"]]
            elif (
                self.template == "Less"
                or self.template == "Percentage"
                or self.template == "HTTP"
            ):  # pylint: disable=line-too-long
                # * The template is equal to `Less`.
                # or
                # * The template is equal to `Percentage`.
                # or
                # * The template is equal to `HTTP`.

                # We get the header with the help of the template name.
                to_print = self.headers[self.template]

                if self.template == "Less" and not PyFunceble.HTTP_CODE["active"]:
                    # * The template is equal to `Less`.
                    # and
                    # * The http status code extraction is deactivated.

                    # We append the source index to the header.
                    to_print["Source"] = 10

            if not PyFunceble.HTTP_CODE["active"]:
                # * The http status code extraction is deactivated.

                # We remove the HTTP Code index from the data to print.
                to_print = Dict(to_print).remove_key("HTTP Code")

            # We update the currently used header.
            self.currently_used_header = to_print

            if not do_not_print:
                # We are not authorized to print anything.

                # We generate the before header.
                self._before_header()

                for formatted_template in self._header_constructor(to_print):
                    # We loop through the formatted template.

                    if not self.only_on_file:
                        # We do not have to print only on file.

                        # We print on screen the formatted header template.
                        print(formatted_template)

                    if not PyFunceble.CONFIGURATION["no_files"] and self.output:
                        # An output destination is given.

                        # We write the file with the formatted header template.
                        File(self.output).write(formatted_template + "\n")
def header(
        self, do_not_print=False
    ):  # pragma: no cover pylint: disable=too-many-branches
        if (
            not PyFunceble.CONFIGURATION["header_printed"]
            or self.template == "Percentage"
            or do_not_print
        ):
            # * The header has not been already printed.
            # or
            # * The template is the `Percentage template`.
            # or
            # * We are authorized to print something.

            if (
                self.template.lower() in PyFunceble.STATUS["list"]["generic"]
                or self.template == "Generic_File"
            ):
                # * The template is into the list of generic status.
                # or
                # * The template is equal to `Generic_File`.

                # The data to print is the Generic header.
                to_print = self.headers["Generic"]

                if (
                    self.template.lower() in PyFunceble.STATUS["list"]["generic"]
                    and PyFunceble.HTTP_CODE["active"]
                ):
                    # * The template is in the list of generic status.
                    # and
                    # * the http status code extraction is activated.

                    # We remove the Analyze Date colomn from the data to print.
                    to_print = Dict(to_print).remove_key("Analyze Date")
            elif self.template.lower() in PyFunceble.STATUS["list"]["up"]:
                # The template is in the list of up status.

                # We informations to print is the up header.
                to_print = self.headers[PyFunceble.STATUS["official"]["up"]]
            elif self.template.lower() in PyFunceble.STATUS["list"]["valid"]:
                # The template is in the list of valid status.

                # We informations to print is the valid header.
                to_print = self.headers[PyFunceble.STATUS["official"]["valid"]]
            elif self.template.lower() in PyFunceble.STATUS["list"]["down"]:
                # The template is in the list of down status.

                # We informations to print is the down header.
                to_print = self.headers[PyFunceble.STATUS["official"]["down"]]
            elif self.template.lower() in PyFunceble.STATUS["list"]["invalid"]:
                # The template is in the list of invalid status.

                # We informations to print is the invalid header.
                to_print = self.headers[PyFunceble.STATUS["official"]["invalid"]]
            elif (
                self.template == "Less"
                or self.template == "Percentage"
                or self.template == "HTTP"
            ):  # pylint: disable=line-too-long
                # * The template is equal to `Less`.
                # or
                # * The template is equal to `Percentage`.
                # or
                # * The template is equal to `HTTP`.

                # We get the header with the help of the template name.
                to_print = self.headers[self.template]

                if self.template == "Less" and not PyFunceble.HTTP_CODE["active"]:
                    # * The template is equal to `Less`.
                    # and
                    # * The http status code extraction is deactivated.

                    # We append the source index to the header.
                    to_print["Source"] = 10

            if not PyFunceble.HTTP_CODE["active"]:
                # * The http status code extraction is deactivated.

                # We remove the HTTP Code index from the data to print.
                to_print = Dict(to_print).remove_key("HTTP Code")

            # We update the currently used header.
            self.currently_used_header = to_print

            if not do_not_print:
                # We are not authorized to print anything.

                # We generate the before header.
                self._before_header()

                for formatted_template in self._header_constructor(to_print):
                    # We loop through the formatted template.

                    if not self.only_on_file:
                        # We do not have to print only on file.

                        # We print on screen the formatted header template.
                        print(formatted_template)

                    if not PyFunceble.CONFIGURATION["no_files"] and self.output:
                        # An output destination is given.

                        # We write the file with the formatted header template.
                        File(self.output).write(formatted_template + "\n")
def header ( self , do_not_print = False ) : # pragma: no cover pylint: disable=too-many-branches if ( not PyFunceble . CONFIGURATION [ "header_printed" ] or self . template == "Percentage" or do_not_print ) : # * The header has not been already printed. # or # * The template is the `Percentage template`. # or # * We are authorized to print something. if ( self . template . lower ( ) in PyFunceble . STATUS [ "list" ] [ "generic" ] or self . template == "Generic_File" ) : # * The template is into the list of generic status. # or # * The template is equal to `Generic_File`. # The data to print is the Generic header. to_print = self . headers [ "Generic" ] if ( self . template . lower ( ) in PyFunceble . STATUS [ "list" ] [ "generic" ] and PyFunceble . HTTP_CODE [ "active" ] ) : # * The template is in the list of generic status. # and # * the http status code extraction is activated. # We remove the Analyze Date colomn from the data to print. to_print = Dict ( to_print ) . remove_key ( "Analyze Date" ) elif self . template . lower ( ) in PyFunceble . STATUS [ "list" ] [ "up" ] : # The template is in the list of up status. # We informations to print is the up header. to_print = self . headers [ PyFunceble . STATUS [ "official" ] [ "up" ] ] elif self . template . lower ( ) in PyFunceble . STATUS [ "list" ] [ "valid" ] : # The template is in the list of valid status. # We informations to print is the valid header. to_print = self . headers [ PyFunceble . STATUS [ "official" ] [ "valid" ] ] elif self . template . lower ( ) in PyFunceble . STATUS [ "list" ] [ "down" ] : # The template is in the list of down status. # We informations to print is the down header. to_print = self . headers [ PyFunceble . STATUS [ "official" ] [ "down" ] ] elif self . template . lower ( ) in PyFunceble . STATUS [ "list" ] [ "invalid" ] : # The template is in the list of invalid status. # We informations to print is the invalid header. to_print = self . headers [ PyFunceble . STATUS [ "official" ] [ "invalid" ] ] elif ( self . template == "Less" or self . template == "Percentage" or self . template == "HTTP" ) : # pylint: disable=line-too-long # * The template is equal to `Less`. # or # * The template is equal to `Percentage`. # or # * The template is equal to `HTTP`. # We get the header with the help of the template name. to_print = self . headers [ self . template ] if self . template == "Less" and not PyFunceble . HTTP_CODE [ "active" ] : # * The template is equal to `Less`. # and # * The http status code extraction is deactivated. # We append the source index to the header. to_print [ "Source" ] = 10 if not PyFunceble . HTTP_CODE [ "active" ] : # * The http status code extraction is deactivated. # We remove the HTTP Code index from the data to print. to_print = Dict ( to_print ) . remove_key ( "HTTP Code" ) # We update the currently used header. self . currently_used_header = to_print if not do_not_print : # We are not authorized to print anything. # We generate the before header. self . _before_header ( ) for formatted_template in self . _header_constructor ( to_print ) : # We loop through the formatted template. if not self . only_on_file : # We do not have to print only on file. # We print on screen the formatted header template. print ( formatted_template ) if not PyFunceble . CONFIGURATION [ "no_files" ] and self . output : # An output destination is given. # We write the file with the formatted header template. File ( self . output ) . write ( formatted_template + "\n" )
Management and creation of templates of header.
        Please consider as "header" the title of each columns.

        :param do_not_print:
            Tell us if we have to print the header or not.
        :type do_not_print: bool
Management and creation of templates of header . Please consider as header the title of each columns .