datakit package¶
Submodules¶
datakit.command_helpers module¶
-
class
datakit.command_helpers.
CommandHelpers
[source]¶ Bases:
object
Mixin class containing common helper methods for Datakit plugins. Intended to be sub-classed alongside Cliff Command.
Usage: - Create a plugin command that subclasses both CommandHelpers and Cliff’s Command class.
- Define
CommandHelpers.plugin_slug
(i.e. the root of plugin’s repo). - Optionally, customize the
CommandHelpers.default_configs
property (which must - return a dictionary)
- Optionally, customize the
Note
default_configs is a property. Please do not forget to use the decorator when you override in a subclass!
Example: from cliff.command import Command from datakit import CommandHelpers class SomeCommand(CommandHelpers, Command): plugin_slug = 'my-plugin' def take_action(self, parsed): print('do stuff') @property def default_configs(self): return { 'foo' : 'bar' }
-
configs
¶
-
default_configs
¶
-
log
= <Logger datakit.command_helpers (WARNING)>¶
-
plugin_config_parent_dir
¶
-
plugin_config_path
¶
-
plugin_slug
= None¶
datakit.datakit_app module¶
-
class
datakit.datakit_app.
Datakit
(*args, **kwargs)[source]¶ Bases:
cliff.app.App
-
build_option_parser
(description, version, argparse_kwargs=None)[source]¶ Return an argparse option parser for this application. Subclasses may override this method to extend the parser with more global options. :param description: full description of the application :paramtype description: str :param version: version number for the application :paramtype version: str :param argparse_kwargs: extra keyword argument passed to the
ArgumentParser constructor
-
print_help_if_requested
()[source]¶ Print help and exits if deferred help is enabled and requested. ‘–help’ shows the help message and exits:
- without calling initialize_app if not self.deferred_help (default),
- after initialize_app call if self.deferred_help,
- during initialize_app call if self.deferred_help and subclass calls explicitly this method in initialize_app.
-
datakit.help module¶
-
class
datakit.help.
HelpAction
(option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None)[source]¶ Bases:
argparse.Action
Provide a custom action so the -h and –help options to the main app will print a list of the commands.
The commands are determined by checking the CommandManager instance, passed in as the “default” value for the action.