Developer Interface¶
Application and Commands¶
-
class
chuda.app.App[source]¶ Base class for create an application in chuda
-
app_name= ''¶ Name of the application, show in the help and version strings
-
config= {}¶ The configuration file will be loaded here
-
config_parser= 'ini'¶ The parser used to parse the configuration file. Possible values are: ini, json, yaml
-
config_path= []¶ Acceptable paths to find the configuration file. Stop searching on the first one exists
-
description= ''¶ Description of the command. Print in help
-
merge_arguments_in_subcommands= True¶ Should
argumentsbe merged in subcommands instead of being accesibble globally ?
-
parser= None¶ Instance of
ArgumentParser
-
plugins= []¶ List of Plugins
-
subcommands= []¶ List of
Command
-
version= '0.0.1'¶ version of your application. Display withe –version flag
-
-
class
chuda.commands.Command[source]¶ A subcommand for multicommands cli tool
-
command_name= None¶ Name of the command, use on the command-line (like “add”, in “git add”)
-
use_subconfig= False¶ Should use config_parser and config_path to generate a config for this command
-
config= {}¶ The configuration file will be loaded here
-
config_parser= 'ini'¶ The parser used to parse the configuration file. Possible values are: ini, json, yaml
-
config_path= []¶ Acceptable paths to find the configuration file. Stop searching on the first one exists
-
merge_parent_arguments= True¶ Should parent arguments be merge with local arguments ? True by default.
-
Arguments¶
-
class
chuda.arguments.Argument(name=None, action='store', nargs=None, const=None, default=None, type=None, choices=None, required=None, help=None, metavar=None, dest=None)[source]¶ Abstract parent class for
OptionandParameter.For attributes who are not documented here, please see
add_argument()documentation-
convert_to_argument()[source]¶ Convert the Argument object to a tuple use in
add_argument()calls on the parser
-
-
class
chuda.arguments.Option(name=None, action='store', nargs=None, const=None, default=None, type=None, choices=None, required=None, help=None, metavar=None, dest=None)[source]¶ Represent an option on the command-line (
mycommand --whatever)-
get_default_name()[source]¶ Return the default generated name to store value on the parser for this option.
eg. An option [‘-s’, ‘–use-ssl’] will generate the use_ssl name
Returns: the default name of the option Return type: str
-
convert_to_argument()[source]¶ Convert the Argument object to a tuple use in
add_argument()calls on the parser
-
-
class
chuda.arguments.Parameter(name=None, action='store', nargs=None, const=None, default=None, type=None, choices=None, required=None, help=None, metavar=None, dest=None)[source]¶ Represent a parameter on the command-line (
mycommand whatever)-
convert_to_argument()[source]¶ Convert the Argument object to a tuple use in
add_argument()calls on the parser
-
Plugins¶
-
class
chuda.plugins.Plugin[source]¶ Class represent a Plugin for a Chuda application A plugin can register hooks for steps in the application lifecycle or enrich the app with new properties
Decorators¶
Shell¶
-
class
chuda.shell.Runner(logger=None, cwd=None)[source]¶ Factory for
ShellCommand-
run(command, block=True, cwd=None, stdin=-1, stdout=-1, stderr=-1)[source]¶ Create an instance of
ShellCommandand run itParameters: - command (str) –
ShellCommand - block (bool) – See
ShellCommand - cwd (str) – Override the runner cwd. Useb by the
ShellCommandinstance
- command (str) –
-
-
class
chuda.shell.ShellCommand(command, logger, cwd=None, block=True, stdin=-1, stdout=-1, stderr=-1)[source]¶ DEPRECATED: Please use sh.py instead
Abstraction layer for shell subprocess
You can disable stdout, stdin, stderr
-
error¶ everything the command will write on stderr will be here
Type: str|list
-
output¶ everything the command will write on stdout will be here
Type: str|list
-
writer¶ Instance of
TextIOWrapperplugged on stdinType: TextIOWrapper
-
run()[source]¶ Run the shell command
Returns: return this ShellCommand instance for chaining Return type: ShellCommand
-
send(value)[source]¶ Send text to stdin. Can only be used on non blocking commands
Parameters: value (str) – the text to write on stdin Raises: TypeError– If command is blockingReturns: return this ShellCommand instance for chaining Return type: ShellCommand
-
poll_output()[source]¶ Append lines from stdout to self.output.
Returns: The lines added since last call Return type: list
-
poll_error()[source]¶ Append lines from stderr to self.errors.
Returns: The lines added since last call Return type: list
-
wait_for(pattern, timeout=None)[source]¶ Block until a pattern have been found in stdout and stderr
Parameters: - pattern (
Pattern) – The pattern to search - timeout (int) – Maximum number of second to wait. If None, wait infinitely
Raises: TimeoutError– When timeout is reach- pattern (
-