Prints

Problematic

How can we print information on the screen and on file in a table format?

Documentation

The tool to check the availability or syntax of domains, IPv4 or URL.

██████╗ ██╗   ██╗███████╗██╗   ██╗███╗   ██╗ ██████╗███████╗██████╗ ██╗     ███████╗
██╔══██╗╚██╗ ██╔╝██╔════╝██║   ██║████╗  ██║██╔════╝██╔════╝██╔══██╗██║     ██╔════╝
██████╔╝ ╚████╔╝ █████╗  ██║   ██║██╔██╗ ██║██║     █████╗  ██████╔╝██║     █████╗
██╔═══╝   ╚██╔╝  ██╔══╝  ██║   ██║██║╚██╗██║██║     ██╔══╝  ██╔══██╗██║     ██╔══╝
██║        ██║   ██║     ╚██████╔╝██║ ╚████║╚██████╗███████╗██████╔╝███████╗███████╗
╚═╝        ╚═╝   ╚═╝      ╚═════╝ ╚═╝  ╚═══╝ ╚═════╝╚══════╝╚═════╝ ╚══════╝╚══════╝

This submodule will provide the printing interface and logic.

Author:
Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom
Special thanks:
https://pyfunceble.github.io/special-thanks.html
Contributors:
https://pyfunceble.github.io/contributors.html
Project link:
https://github.com/funilrys/PyFunceble
Project documentation:
https://pyfunceble.readthedocs.io/en/master/
Project homepage:
https://pyfunceble.github.io/

License:

MIT License

Copyright (c) 2017, 2018, 2019 Nissar Chababy

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
class PyFunceble.prints.Prints(to_print, template, output_file=None, only_on_file=False)[source]

Print data on screen and into a file if needed. Template Possibilities: Percentage, Less, HTTP and any status you want.

Parameters:
  • to_print (list) – The list of data to print.
  • template (str) –

    The template to use.

    Note

    Available templates:

    • Percentage
    • Less
    • HTTP
    • any of the official status.
  • output_file (str) – The path to the file to write.
  • only_on_file (bool) – Tell us if we only have to print on file and not on screen.
_before_header()[source]

Print informations about PyFunceble and the date of generation of a file into a given path, if doesn’t exist.

_colorify(data)[source]

Retun colored string.

Parameters:data (str) – The string to colorify.
Returns:A colored string.
Return type:str
_data_constructor(size)[source]

Construct the table of data according to given size.

Parameters:

size (list) – The maximal length of each string in the table.

Returns:

A dict with all information about the data and how to which what maximal size to print it.

Return type:

OrderedDict

Raises:
Exception

If the data and the size does not have the same length.

classmethod _header_constructor(data_to_print, header_separator='-', column_separator=' ')[source]

Construct header of the table according to template.

Parameters:
  • data_to_print (list) – The list of data to print into the header of the table.
  • header_separator (str) – The separator to use between the table header and our data.
  • colomn_separator (str) – The separator to use between each colomns.
Returns:

The data to print in a list format.

Return type:

list

_json_print()[source]

Management of the json template.

classmethod _size_from_header(header)[source]

Get the size of each columns from the header.

Parameters:header (dict) – The header template we have to get the size from.
Returns:The maximal size of the each data to print.
Return type:list
data()[source]

Management and input of data to the table.

Raises:
Exception

When self.data_to_print is not a list.

header(do_not_print=False)[source]

Management and creation of templates of header. Please consider as “header” the title of each columns.

Parameters:do_not_print (bool) – Tell us if we have to print the header or not.