Subpackage with formatter classes used to render and output results.
Each formatter has a Formatter.produce_output() method taking one argument which gets rendered and printed to output stream. Each formatter expects different argument, please refer to doc string of particular class.
Renders data in a csv (Comma-separated values) format.
Base formatter class.
It produces string representation of given argument and prints it.
This formatter supports following commands:
Parameters: |
|
---|
Try to determine encoding for output terminal.
Returns: | Encoding used to encode unicode strings. |
---|---|
Return type: | string |
counter of hosts printed
counter of lines producted for current table
Prints header for new host.
Parameters: | hostname (string) – Hostname to print. |
---|
Prints single line. Output message is prefixed with padding spaces, formated and printed to output stream.
Parameters: |
|
---|
Render and print given data.
Data can be also instance of FormatterCommand, see documentation of this class for list of allowed commands.
This shall be overridden by subclasses.
Parameters: | data – Any value to print. Subclasses may specify their requirements for this argument. It can be also am instance of FormatterCommand. |
---|
Rendering function for single value.
Parameters: | val – Any value to render. |
---|---|
Returns: | Value converted to its string representation. |
Return type: | str |
counter of tables produced for current host
Base formatter taking care of list of items. It renders input data in a form of table with mandatory column names at the beginning followed by items, one occupying single line (row).
The command must be provided as content of one row. This row is then not printed and the command is executed.
This class should be subclassed to provide nice output.
Print data row. Optionaly print header, if requested.
Parameters: | data (tuple) – Data to print. |
---|
Prints title of next tale.
Parameters: | title (string) – Title to print. |
---|
Print data row without any header.
Parameters: | row (tuple) – Data to print. |
---|
Prints list of rows.
There can be a FormatterCommand instance instead of a row. See documentation of this class for list of allowed commands.
Parameters: | rows (list, generator or command.FormatterCommand) – List of rows to print. |
---|
Specialization of SingleFormatter having its output executable as a shell script.
Meant to render and print attributes of single object. Attributes are rendered as a list of assignments of values to variables (attribute names).
Render and print attributes of single item.
There can be a FormatterCommand instance instead of a data. See documentation of this class for list of allowed commands.
Parameters: | data (tuple or dict) – Is either a pair of property names with list of values or a dictionary with property names as keys. Using the pair allows to order the data the way it should be printing. In the latter case the properties will be sorted by the property names. |
---|
Print nice human-readable table to terminal.
To print the table nicely aligned, the whole table must be populated first. Therefore this formatter stores all rows locally and does not print them until the table is complete. Column sizes are computed afterwards and the table is printed at once.
The command must be provided as content of one row. This row is then not printed and the command is executed.
Prints header for new host.
Parameters: | hostname (string) – Hostname to print. |
---|
Prints title of next tale.
Parameters: | title (string) – Title to print. |
---|
Prints list of rows.
There can be FormatterCommand instance instead of a row. See documentation of this class for list of allowed commands.
Parameters: | rows (list or generator) – List of rows to print. |
---|