taucmdr.cli.cli_view module¶
A command line data view.
See http://en.wikipedia.org/wiki/Model-view-controller
- class taucmdr.cli.cli_view.AbstractCliView(model, module_name, summary_fmt=None, help_page_fmt=None, group=None, include_storage_flag=True)[source]¶
Bases:
AbstractCommandA command that works as a view for a controller.
See http://en.wikipedia.org/wiki/Model-view-controller
- controller¶
The controller class for this view’s data.
- Type:
class
- _abc_impl = <_abc._abc_data object>¶
- class taucmdr.cli.cli_view.CopyCommand(*args, **kwargs)[source]¶
Bases:
CreateCommandBase class for the copy subcommand of command line views.
- _abc_impl = <_abc._abc_data object>¶
- class taucmdr.cli.cli_view.CreateCommand(*args, **kwargs)[source]¶
Bases:
AbstractCliViewBase class for the create command of command line views.
- _abc_impl = <_abc._abc_data object>¶
- _create_record(store, data)[source]¶
Create the model record.
- Parameters:
store (AbstractStorage) – Storage to contain the record.
data (dict) – Record data.
- Returns:
EXIT_SUCCESSif successful.- Return type:
- Raises:
UniqueAttributeError – A record with the same unique attribute already exists.
- class taucmdr.cli.cli_view.DeleteCommand(*args, **kwargs)[source]¶
Bases:
AbstractCliViewBase class for the delete subcommand of command line views.
- _abc_impl = <_abc._abc_data object>¶
- class taucmdr.cli.cli_view.EditCommand(*args, **kwargs)[source]¶
Bases:
AbstractCliViewBase class for the edit subcommand of command line views.
- _abc_impl = <_abc._abc_data object>¶
- class taucmdr.cli.cli_view.ListCommand(*args, **kwargs)[source]¶
Bases:
AbstractCliViewBase class for the list subcommand of command line views.
- _abc_impl = <_abc._abc_data object>¶
- _count_records(ctrl)[source]¶
Print a record count to stdout.
- Parameters:
controller (Controller) – Controller for the data model.
- _format_records(ctrl, style, keys=None, context=True)[source]¶
Format records in a given style.
Retrieves records for controller ctrl and formats them.
- Parameters:
ctrl (Controller) – Controller for the data model.
style (str) – Style in which to format records.
keys (list) – Keys to match to the model’s key attribute.
- Returns:
Record data as formatted strings.
- Return type:
- _list_records(storage_levels, keys, style, context=True)[source]¶
Shows record data via print.
- Parameters:
- Returns:
EXIT_SUCCESSif successful.- Return type:
- _retrieve_records(ctrl, keys, context=True)[source]¶
Retrieve modeled data from the controller.
- Parameters:
ctrl (Controller) – Controller for the data model.
keys (list) – Keys to match to the model’s key attribute.
- Returns:
Model records.
- Return type:
- dashboard_format(records)[source]¶
Format modeled records in dashboard format.
- Parameters:
records – Modeled records to format.
- Returns:
Record data in dashboard format.
- Return type:
- long_format(records)[source]¶
Format records in long format.
- Parameters:
records – Controlled records to format.
- Returns:
Record data in long format.
- Return type:
- class taucmdr.cli.cli_view.RootCommand(model, module_name, summary_fmt=None, help_page_fmt=None, group=None, include_storage_flag=True)[source]¶
Bases:
AbstractCliViewA command with subcommands for actions.
- _abc_impl = <_abc._abc_data object>¶
- class taucmdr.cli.cli_view.Texttable(max_width=80)[source]¶
Bases:
TexttableExtend the Texttable class to print header rows in bold.
- _draw_line(line, isheader=False)[source]¶
Override original Texttable’s _draw_line() method to make headers bold.
Draws a line by looping over a single cell length, over all the cells, making any header text bold. A better place to implement this would have been _splitit() but the logic in texttable does not strip ANSI escape sequences and treats them as printable characters. texttable 1.6.3 and 1.7.1 have the same _draw_line. Adapted from texttable v1.6.3: https://github.com/foutaise/texttable/blob/4073cefdfc4e5c50ed587909875b64b005c70df8/texttable.py#L657-L686