:mod:`cloudmesh-common.cloudmesh.common.Tabulate` ================================================= .. py:module:: cloudmesh-common.cloudmesh.common.Tabulate Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: cloudmesh-common.cloudmesh.common.Tabulate.Printer .. class:: Printer formats supported dict, yaml, json set table.format=table cms flavor list +-----------+---------+-------+--------+ | Name | VCPUS | RAM | Disk | |-----------+---------+-------+--------| | m1.tiny | 1 | 512 | 1 | | m1.small | 1 | 2048 | 20 | | m1.medium | 2 | 4096 | 40 | | m1.large | 4 | 8192 | 40 | | m1.xlarge | 8 | 16384 | 40 | +-----------+---------+-------+--------+ set table.format=grid cms flavor list ╒═══════════╤═════════╤═══════╤════════╕ │ Name │ VCPUS │ RAM │ Disk │ ╞═══════════╪═════════╪═══════╪════════╡ │ m1.tiny │ 1 │ 512 │ 1 │ ├───────────┼─────────┼───────┼────────┤ │ m1.small │ 1 │ 2048 │ 20 │ ├───────────┼─────────┼───────┼────────┤ │ m1.medium │ 2 │ 4096 │ 40 │ ├───────────┼─────────┼───────┼────────┤ │ m1.large │ 4 │ 8192 │ 40 │ ├───────────┼─────────┼───────┼────────┤ │ m1.xlarge │ 8 │ 16384 │ 40 │ ╘═══════════╧═════════╧═══════╧════════╛ .. method:: default() :staticmethod: .. method:: select(results, order=None, width=None) :staticmethod: selects field in the order as defined in order If order is non, all fileds will be taken :param results: a flat dict :param order: the order of the fields :param width: :return: a list of dicts .. method:: write(results, order=None, header=None, output='table', width=None, humanize=False, max_width=None, sep='.') :staticmethod: .. method:: _to_tabulate(d) :staticmethod: :param d: dict of dicts :return: list of dicts with the key as name .. method:: flatwrite(table, order=None, header=None, output='table', sort_keys=True, show_none='', humanize=None, sep='.', max_width=48, width=48) :staticmethod: 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 width: maximum width for a cell :type width: int :param max_width: deprecated use width :type max_width: int :return: .. method:: attribute(cls, d, header=None, order=None, sort_keys=True, humanize=None, output='table', width=70) :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:: 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