The oslo_reports.views.text.generic Module

Provides generic text views

This modules provides several generic views for serializing models into human-readable text.

class oslo_reports.views.text.generic.BasicKeyValueView

Bases: object

A Basic Key-Value Text View

This view performs a naive serialization of a model into text using a basic key-value method, where each key-value pair is rendered as “key = str(value)”

class oslo_reports.views.text.generic.KeyValueView(indent_str=' ', key_sep=' = ', dict_sep=' = ', list_sep=' = ', anon_dict='[dict]', before_dict=None, before_list=None)

Bases: object

A Key-Value Text View

This view performs an advanced serialization of a model into text by following the following set of rules:

key : text
key = text
rootkey : Mapping
rootkey =
  serialize(key, value)
key : Sequence
key =
  serialize(item)
Parameters:
  • indent_str (str) – the string used to represent one “indent”
  • key_sep (str) – the separator to use between keys and values
  • dict_sep (str) – the separator to use after a dictionary root key
  • list_sep (str) – the separator to use after a list root key
  • anon_dict (str) – the “key” to use when there is a dict in a list (does not automatically use the dict separator)
  • before_dict (str or None) – content to place on the line(s) before the a dict root key (use None to avoid inserting an extra line)
  • before_list (str or None) – content to place on the line(s) before the a list root key (use None to avoid inserting an extra line)
class oslo_reports.views.text.generic.MultiView

Bases: object

A Text View Containing Multiple Views

This view simply serializes each value in the data model, and then joins them with newlines (ignoring the key values altogether). This is useful for serializing lists of models (as array-like dicts).

class oslo_reports.views.text.generic.TableView(column_names, column_values, table_prop_name)

Bases: object

A Basic Table Text View

This view performs serialization of data into a basic table with predefined column names and mappings. Column width is auto-calculated evenly, column values are automatically truncated accordingly. Values are centered in the columns.

Parameters:
  • column_names ([str]) – the headers for each of the columns
  • column_values ([str]) – the item name to match each column to in each row
  • table_prop_name (str) – the name of the property within the model containing the row models