:mod:`cloudmesh-common.cloudmesh.common.Printer` ================================================ .. py:module:: cloudmesh-common.cloudmesh.common.Printer .. autoapi-nested-parse:: Convenient methods and classes to print tables. Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: cloudmesh-common.cloudmesh.common.Printer.Printer .. class:: Printer Bases: :class:`object` A simple Printer class with convenient methods to print dictionary, tables, csv, lists .. method:: flatwrite(cls, table, order=None, header=None, output='table', sort_keys=True, show_none='', humanize=None, sep='.', max_width=48) :classmethod: writes the information given in the table :param table: the table of values :param order: the order of the columns :param header: the header for the columns :param output: the format (default is table, values are raw, csv, json, yaml, dict :param sort_keys: if true the table is sorted :param show_none: passed along to the list or dict printer :param sep: uses sep as the separator for csv printer :param max_width: maximum width for a cell :type max_width: int :return: .. method:: write(cls, table, order=None, header=None, output='table', sort_keys=True, humanize=None, show_none='', max_width=48) :classmethod: writes the information given in the table :param table: the table of values :param order: the order of the columns :param header: the header for the columns :param output: the format (default is table, values are raw, csv, json, yaml, dict :param sort_keys: if true the table is sorted :param show_none: passed along to the list or dict printer :param max_width: maximum width for a cell :type max_width: int :return: .. method:: list(cls, l, order=None, header=None, output='table', sort_keys=True, humanize=None, show_none='', max_width=48) :classmethod: :param l: l is a list not a dict :param order: :param header: :param output: :param sort_keys: :param show_none: :param max_width: maximum width for a cell :type max_width: int :return: .. method:: dict(cls, d, order=None, header=None, output='table', sort_keys=True, humanize=None, show_none='', max_width=48) :classmethod: :param d: A a dict with dicts of the same type. :type d: dict :param order: The order in which the columns are printed. The order is specified by the key names of the dict. :type order: list :param header: The Header of each of the columns :type header: list or tuple of field names :param output: type of output (table, csv, json, yaml or dict) :type output: string :param sort_keys: list :type sort_keys: bool :param show_none: prints None if True for None values otherwise "" :type show_none: string :param max_width: maximum width for a cell :type max_width: int :return: .. method:: csv(cls, d, order=None, header=None, humanize=None, sort_keys=True) :classmethod: prints a table in csv format :param d: A a dict with dicts of the same type. :type d: dict :param order: The order in which the columns are printed. The order is specified by the key names of the dict. :type order: :param header: The Header of each of the columns :type header: list or tuple of field names :param sort_keys: TODO - not yet implemented :type sort_keys: bool :return: a string representing the table in csv format .. method:: dict_html(cls, d, order=None, header=None, sort_keys=True, show_none='', humanize=None, max_width=48) :classmethod: .. method:: dict_table(cls, d, order=None, header=None, sort_keys=True, show_none='', humanize=None, max_width=48) :classmethod: prints a pretty table from an dict of dicts :param d: A a dict with dicts of the same type. Each key will be a column :param order: The order in which the columns are printed. The order is specified by the key names of the dict. :param header: The Header of each of the columns :type header: A list of string :param sort_keys: Key(s) of the dict to be used for sorting. This specify the column(s) in the table for sorting. :type sort_keys: string or a tuple of string (for sorting with multiple columns) :param show_none: prints None if True for None values :type show_none: string :param max_width: maximum width for a cell :type max_width: int .. method:: attribute(cls, d, header=None, order=None, sort_keys=True, humanize=None, output='table') :classmethod: prints a attribute/key value table :param d: A a dict with dicts of the same type. Each key will be a column :param order: The order in which the columns are printed. The order is specified by the key names of the dict. :param header: The Header of each of the columns :type header: A list of string :param sort_keys: Key(s) of the dict to be used for sorting. This specify the column(s) in the table for sorting. :type sort_keys: string or a tuple of string (for sorting with multiple columns) :param output: the output format table, csv, dict, json .. method:: print_list(cls, l, output='table') :classmethod: prints a list :param l: the list :param output: the output, default is a table :return: .. method:: row_table(cls, d, order=None, labels=None) :classmethod: prints a pretty table from data in the dict. :param d: A dict to be printed :param order: The order in which the columns are printed. The order is specified by the key names of the dict. :param labels: The array of labels for the column