PyFunceble/prints.py
def _before_header(self):
        """
        Print informations about PyFunceble and the date of generation of a file
        into a given path, if doesn't exist.
        """

        if (
            not PyFunceble.CONFIGURATION["no_files"]
            and self.output
            and not PyFunceble.path.isfile(self.output)
        ):
            # * We are allowed to generate files.
            # and
            # * And output is given.
            # and
            # * The given output does not exist.

            # We initiate the information about what generated the file.
            link = "# File generated by %s\n" % PyFunceble.LINKS["repo"]

            # We initiate the information about the generation date of this file.
            date_of_generation = (
                "# Date of generation: %s \n\n" % PyFunceble.CURRENT_TIME
            )

            # We initiate a variable which will save the list of
            # templates which have to meet in order to write the before
            # header informations.
            authorized_templates = [
                "Generic_File",
                PyFunceble.STATUS["official"]["up"],
                PyFunceble.STATUS["official"]["down"],
                PyFunceble.STATUS["official"]["invalid"],
                PyFunceble.STATUS["official"]["valid"],
                "Less",
            ]

            if self.template in authorized_templates:
                # The current header is in our list of authorized templated.

                # We get the header.
                header = (
                    self._header_constructor(self.currently_used_header, None)[0] + "\n"
                )

            try:
                # We try to print the link, the date of generation and the header in the
                # given file.
                File(self.output).write(link + date_of_generation + header)
            except UnboundLocalError:
                # We don't have any header.

                # We print the link and the date in the given file.
                File(self.output).write(link + date_of_generation)
def _before_header(self):
        """
        Print informations about PyFunceble and the date of generation of a file
        into a given path, if doesn't exist.
        """

        if (
            not PyFunceble.CONFIGURATION["no_files"]
            and self.output
            and not PyFunceble.path.isfile(self.output)
        ):
            # * We are allowed to generate files.
            # and
            # * And output is given.
            # and
            # * The given output does not exist.

            # We initiate the information about what generated the file.
            link = "# File generated by %s\n" % PyFunceble.LINKS["repo"]

            # We initiate the information about the generation date of this file.
            date_of_generation = (
                "# Date of generation: %s \n\n" % PyFunceble.CURRENT_TIME
            )

            # We initiate a variable which will save the list of
            # templates which have to meet in order to write the before
            # header informations.
            authorized_templates = [
                "Generic_File",
                PyFunceble.STATUS["official"]["up"],
                PyFunceble.STATUS["official"]["down"],
                PyFunceble.STATUS["official"]["invalid"],
                PyFunceble.STATUS["official"]["valid"],
                "Less",
            ]

            if self.template in authorized_templates:
                # The current header is in our list of authorized templated.

                # We get the header.
                header = (
                    self._header_constructor(self.currently_used_header, None)[0] + "\n"
                )

            try:
                # We try to print the link, the date of generation and the header in the
                # given file.
                File(self.output).write(link + date_of_generation + header)
            except UnboundLocalError:
                # We don't have any header.

                # We print the link and the date in the given file.
                File(self.output).write(link + date_of_generation)
Print informations about PyFunceble and the date of generation of a file
        into a given path, if doesn't exist.