The watcherclient.common.utils Module¶
-
class
watcherclient.common.utils.HelpFormatter(prog, indent_increment=2, max_help_position=24, width=None)[source]¶ Bases:
argparse.HelpFormatter
-
watcherclient.common.utils.common_filters(limit=None, sort_key=None, sort_dir=None)[source]¶ Generate common filters for any list request.
Parameters: - limit – maximum number of entities to return.
- sort_key – field to use for sorting.
- sort_dir – direction of sorting: ‘asc’ or ‘desc’.
Returns: list of string filters.
-
watcherclient.common.utils.common_params_for_list(args, fields, field_labels)[source]¶ Generate ‘params’ dict that is common for every ‘list’ command.
Parameters: - args – arguments from command line.
- fields – possible fields for sorting.
- field_labels – possible field labels for sorting.
Returns: a dict with params to pass to the client method.
-
watcherclient.common.utils.define_command(subparsers, command, callback, cmd_mapper)[source]¶ Define a command in the subparsers collection.
Parameters: - subparsers – subparsers collection where the command will go
- command – command name
- callback – function that will be used to process the command
-
watcherclient.common.utils.define_commands_from_module(subparsers, command_module, cmd_mapper)[source]¶ Add do_ methods in a module and add as commands into a subparsers.