woob.tools.application.repl
¶
-
exception
woob.tools.application.repl.
ArgSyntaxError
¶ Bases:
Exception
-
exception
woob.tools.application.repl.
NotEnoughArguments
¶ Bases:
Exception
-
class
woob.tools.application.repl.
ReplApplication
¶ Bases:
woob.tools.application.console.ConsoleApplication
,woob.tools.application.repl.MyCmd
Base application class for Repl applications.
Instantiate a line-oriented interpreter framework.
The optional argument ‘completekey’ is the readline name of a completion key; it defaults to the Tab key. If completekey is not None and the readline module is available, command completion is done automatically. The optional arguments stdin and stdout specify alternate input and output file objects; if not specified, sys.stdin and sys.stdout are used.
-
COLLECTION_OBJECTS
= ()¶ Objects to allow in do_ls / do_cd
-
COMMANDS_FORMATTERS
= {}¶
-
DEFAULT_FORMATTER
= 'multiline'¶
-
DISABLE_REPL
= False¶
-
EXTRA_FORMATTERS
= {}¶
-
SYNOPSIS
= 'Usage: %prog [-dqv] [-b backends] [-cnfs] [command [arguments..]]\n %prog [--help] [--version]'¶
-
add_object
(obj)¶
-
all_collections
()¶ Get all objects that are collections: regular objects and fake dumb objects.
-
bcall_error_handler
(backend, error, backtrace)¶ Handler for an exception inside the CallErrors exception.
This method can be overridden to support more exceptions types.
-
bcall_errors_handler
(errors, ignore=())¶ Handler for the CallErrors exception.
-
cached_format
(obj)¶
-
change_path
(split_path)¶
-
comp_key
(obj)¶
-
complete
(text, state)¶ Override of the Cmd.complete() method to:
add a space at end of proposals
display only proposals for words which match the text already written by user.
-
complete_backends
(text, line, begidx, endidx)¶
-
complete_cd
(text, line, begidx, endidx)¶
-
complete_formatter
(text, line, *ignored)¶
-
complete_logging
(text, line, begidx, endidx)¶
-
complete_ls
(text, line, begidx, endidx)¶
-
complete_path
(text, line, begidx, endidx)¶
-
completenames
(text, *ignored)¶
-
default
(line)¶ Called on an input line when the command prefix is not recognized.
If this method is not overridden, it prints an error message and returns.
-
do
(function, *args, **kwargs)¶ Call Woob.do(), passing count and selected fields given by user.
-
do_EOF
(arg)¶ Quit the command line interpreter when ^D is pressed.
-
do_backends
(line)¶ backends [ACTION] [BACKEND_NAME]…
Select used backends.
- ACTION is one of the following (default: list):
enable enable given backends
disable disable given backends
only enable given backends and disable the others
list list backends
add add a backend
register register a new account on a website
edit edit a backend
remove remove a backend
list-modules list modules
-
do_cd
(line)¶ cd [PATH]
Follow a path. “..” is a special case and goes up one directory. “” is a special case and goes home.
-
do_condition
(line)¶ condition [EXPRESSION | off]
If an argument is given, set the condition expression used to filter the results. See CONDITION section for more details and the expression. If the “off” value is given, conditional filtering is disabled.
If no argument is given, print the current condition expression.
-
do_count
(line)¶ count [NUMBER | off]
If an argument is given, set the maximum number of results fetched. NUMBER must be at least 1. “off” value disables counting, and allows infinite searches.
If no argument is given, print the current count value.
-
do_debug
(line)¶ debug
Launch a debug Python shell
-
do_formatter
(line)¶ formatter [list | FORMATTER [COMMAND] | option OPTION_NAME [on | off]]
If a FORMATTER is given, set the formatter to use. You can add a COMMAND to apply the formatter change only to a given command.
If the argument is “list”, print the available formatters.
If the argument is “option”, set the formatter options. Valid options are: header, keys. If on/off value is given, set the value of the option. If not, print the current value for the option.
If no argument is given, print the current formatter.
-
do_help
(arg=None)¶ help [COMMAND]
List commands, or get information about a command.
-
do_logging
(line)¶ logging [LEVEL]
Set logging level.
Availables: debug, info, warning, error. * quiet is an alias for error * default is an alias for warning
-
do_ls
(*args, **kwargs)¶ ls [-d] [-U] [PATH]
List objects in current path. If an argument is given, list the specified path. Use -U option to not sort results. It allows you to use a “fast path” to return results as soon as possible. Use -d option to display information about a collection (and to not display the content of it). It has the same behavior than the well known UNIX “ls” command.
Default is limited to 40 results.
-
do_quit
(arg)¶ Quit the application.
-
do_select
(line)¶ select [FIELD_NAME]… | “$direct” | “$full”
If an argument is given, set the selected fields. $direct selects all fields loaded in one http request. $full selects all fields using as much http requests as necessary.
If no argument is given, print the currently selected fields.
-
emptyline
()¶ By default, an emptyline repeats the previous command. Overriding this function disables this behaviour.
-
flush
()¶
-
format
(result, alias=None)¶
-
get_command_help
(command, short=False)¶
-
get_commands_doc
()¶
-
get_object
(_id, method, fields=None, caps=None)¶
-
get_object_list
(method=None, *args, **kwargs)¶
-
property
interactive
¶
-
load_backends
(*args, **kwargs)¶
-
main
(argv)¶ Main method
Called by run
-
obj_to_filename
(obj, dest=None, default=None)¶ This method can be used to get a filename from an object, using a mask filled by information of this object.
All patterns are braces-enclosed, and are name of available fields in the object.
- Parameters
obj (BaseObject) – object
dest (str) – dest given by user (default None)
default (str) – default file mask (if not given, this is ‘{id}-{title}.{ext}’)
- Return type
str
-
onecmd
(line)¶ This REPL method is overridden to catch some particular exceptions.
-
parse_command_args
(line, nb, req_n=None)¶
-
parse_fields
(fields)¶
-
parse_id
(id, unique_backend=False)¶
-
parseline
(line)¶ This REPL method is overridden to search “short” alias of commands
-
path_completer
(arg)¶
-
postcmd
(stop, line)¶ This REPL method is overridden to return None instead of integers to prevent stopping cmdloop().
-
set_formatter
(name)¶ Set the current formatter from name.
It returns the name of the formatter which has been really set.
-
set_formatter_header
(string)¶
-
start_format
(**kwargs)¶
-
unload_backends
(*args, **kwargs)¶
-
woob_commands
= {'backends', 'cd', 'condition', 'count', 'formatter', 'logging', 'ls', 'quit', 'select'}¶
-
-
exception
woob.tools.application.repl.
TooManyArguments
¶ Bases:
Exception