PyFunceble/prints.py
def data(self):  #  pragma: no cover  pylint: disable=inconsistent-return-statements
        """
        Management and input of data to the table.

        :raises:
            :code:`Exception`
                When self.data_to_print is not a list.
        """

        if isinstance(self.data_to_print, list):
            # The data to print is a list.

            # We initiate the data we are going to print.
            to_print = {}

            # We initiate the size we are going to print.
            to_print_size = []

            # We initiate a variable which will list the list of
            # alone case.
            alone_cases = ["Percentage", "HTTP"]

            # we initiate a variable which will list the list of
            # template which does not need a header.
            without_header = ["FullHosts", "PlainDomain"]

            if self.template.lower() == "json":
                # The template is the json template.

                if not PyFunceble.CONFIGURATION["no_files"] and self.output:
                    # * We are allowed to generate file.
                    # and
                    # * The given output is not empty.

                    # We print the json file.
                    return self._json_print()

                # We return nothing.
                return None

            if self.template not in alone_cases and self.template not in without_header:
                # * The template is not in the list of alone case.
                # and
                # * THe template is not in the list of template without header.

                # We get the template we should use.
                # Note: We basically only need the self.currently_used_header to be filled.
                self.header(True)

                # And we get the size from the header.
                to_print_size = self._size_from_header(self.currently_used_header)
            elif self.template in without_header:
                # The template is in the list of template which does not need a header.

                for data in self.data_to_print:
                    # We loop through the list of data to print.

                    # And we construct the (spacement) size of the data to print.
                    to_print_size.append(str(len(data)))
            else:
                # We get the size from the given template name.
                to_print_size = self._size_from_header(self.headers[self.template])

            # We construct and format the data to print.
            to_print = self._data_constructor(to_print_size)

            # We print the before header section.
            self._before_header()

            for data in self._header_constructor(to_print, False):
                # We loop through the formatted data.

                if self.template.lower() in PyFunceble.STATUS["list"][
                    "generic"
                ] or self.template in ["Less", "Percentage"]:
                    # * The template is in the list of generic status.
                    # or
                    # * The template is in a specific list.

                    if not self.only_on_file:
                        # We are authorized to print on screen.

                        # We colorify the data to print.
                        colorified_data = self._colorify(data)

                        # And we print the data.
                        print(colorified_data)
                if not PyFunceble.CONFIGURATION["no_files"] and self.output:
                    # * We are authorized to print on any file.
                    # and
                    # * The output is given.

                    # We write our data into the printed file.
                    File(self.output).write(data + "\n")
        else:
            # This should never happend. If it's happens then there's a big issue
            # around data_to_print.
            raise Exception("Please review Prints().data()")
def data(self):  #  pragma: no cover  pylint: disable=inconsistent-return-statements
        if isinstance(self.data_to_print, list):
            # The data to print is a list.

            # We initiate the data we are going to print.
            to_print = {}

            # We initiate the size we are going to print.
            to_print_size = []

            # We initiate a variable which will list the list of
            # alone case.
            alone_cases = ["Percentage", "HTTP"]

            # we initiate a variable which will list the list of
            # template which does not need a header.
            without_header = ["FullHosts", "PlainDomain"]

            if self.template.lower() == "json":
                # The template is the json template.

                if not PyFunceble.CONFIGURATION["no_files"] and self.output:
                    # * We are allowed to generate file.
                    # and
                    # * The given output is not empty.

                    # We print the json file.
                    return self._json_print()

                # We return nothing.
                return None

            if self.template not in alone_cases and self.template not in without_header:
                # * The template is not in the list of alone case.
                # and
                # * THe template is not in the list of template without header.

                # We get the template we should use.
                # Note: We basically only need the self.currently_used_header to be filled.
                self.header(True)

                # And we get the size from the header.
                to_print_size = self._size_from_header(self.currently_used_header)
            elif self.template in without_header:
                # The template is in the list of template which does not need a header.

                for data in self.data_to_print:
                    # We loop through the list of data to print.

                    # And we construct the (spacement) size of the data to print.
                    to_print_size.append(str(len(data)))
            else:
                # We get the size from the given template name.
                to_print_size = self._size_from_header(self.headers[self.template])

            # We construct and format the data to print.
            to_print = self._data_constructor(to_print_size)

            # We print the before header section.
            self._before_header()

            for data in self._header_constructor(to_print, False):
                # We loop through the formatted data.

                if self.template.lower() in PyFunceble.STATUS["list"][
                    "generic"
                ] or self.template in ["Less", "Percentage"]:
                    # * The template is in the list of generic status.
                    # or
                    # * The template is in a specific list.

                    if not self.only_on_file:
                        # We are authorized to print on screen.

                        # We colorify the data to print.
                        colorified_data = self._colorify(data)

                        # And we print the data.
                        print(colorified_data)
                if not PyFunceble.CONFIGURATION["no_files"] and self.output:
                    # * We are authorized to print on any file.
                    # and
                    # * The output is given.

                    # We write our data into the printed file.
                    File(self.output).write(data + "\n")
        else:
            # This should never happend. If it's happens then there's a big issue
            # around data_to_print.
            raise Exception("Please review Prints().data()")
def data ( self ) : #  pragma: no cover  pylint: disable=inconsistent-return-statements if isinstance ( self . data_to_print , list ) : # The data to print is a list. # We initiate the data we are going to print. to_print = { } # We initiate the size we are going to print. to_print_size = [ ] # We initiate a variable which will list the list of # alone case. alone_cases = [ "Percentage" , "HTTP" ] # we initiate a variable which will list the list of # template which does not need a header. without_header = [ "FullHosts" , "PlainDomain" ] if self . template . lower ( ) == "json" : # The template is the json template. if not PyFunceble . CONFIGURATION [ "no_files" ] and self . output : # * We are allowed to generate file. # and # * The given output is not empty. # We print the json file. return self . _json_print ( ) # We return nothing. return None if self . template not in alone_cases and self . template not in without_header : # * The template is not in the list of alone case. # and # * THe template is not in the list of template without header. # We get the template we should use. # Note: We basically only need the self.currently_used_header to be filled. self . header ( True ) # And we get the size from the header. to_print_size = self . _size_from_header ( self . currently_used_header ) elif self . template in without_header : # The template is in the list of template which does not need a header. for data in self . data_to_print : # We loop through the list of data to print. # And we construct the (spacement) size of the data to print. to_print_size . append ( str ( len ( data ) ) ) else : # We get the size from the given template name. to_print_size = self . _size_from_header ( self . headers [ self . template ] ) # We construct and format the data to print. to_print = self . _data_constructor ( to_print_size ) # We print the before header section. self . _before_header ( ) for data in self . _header_constructor ( to_print , False ) : # We loop through the formatted data. if self . template . lower ( ) in PyFunceble . STATUS [ "list" ] [ "generic" ] or self . template in [ "Less" , "Percentage" ] : # * The template is in the list of generic status. # or # * The template is in a specific list. if not self . only_on_file : # We are authorized to print on screen. # We colorify the data to print. colorified_data = self . _colorify ( data ) # And we print the data. print ( colorified_data ) if not PyFunceble . CONFIGURATION [ "no_files" ] and self . output : # * We are authorized to print on any file. # and # * The output is given. # We write our data into the printed file. File ( self . output ) . write ( data + "\n" ) else : # This should never happend. If it's happens then there's a big issue # around data_to_print. raise Exception ( "Please review Prints().data()" )
Management and input of data to the table.

        :raises:
            :code:`Exception`
                When self.data_to_print is not a list.
Management and input of data to the table .