woob.tools.application.repl
¶
- class ReplApplication[source]¶
Bases:
ConsoleApplication
,Cmd
Base application class for Repl applications.
- SYNOPSIS = 'Usage: %prog [-dqv] [-b backends] [-cnfs] [command [arguments..]]\n %prog [--help] [--version]'¶
- DISABLE_REPL = False¶
- EXTRA_FORMATTERS = {}¶
- DEFAULT_FORMATTER = 'multiline'¶
- COMMANDS_FORMATTERS = {}¶
- COLLECTION_OBJECTS = ()¶
Objects to allow in do_ls / do_cd
- woob_commands = {'backends', 'cd', 'condition', 'count', 'formatter', 'logging', 'ls', 'quit', 'select', 'storage'}¶
- property interactive¶
- do(function, *args, **kwargs)[source]¶
Call Woob.do(), passing count and selected fields given by user.
- postcmd(stop, line)[source]¶
This REPL method is overridden to return None instead of integers to prevent stopping cmdloop().
- emptyline()[source]¶
By default, an emptyline repeats the previous command. Overriding this function disables this behaviour.
- default(line)[source]¶
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.
- complete(text, state)[source]¶
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.
- bcall_error_handler(backend, error, backtrace)[source]¶
Handler for an exception inside the CallErrors exception.
This method can be overridden to support more exceptions types.
- do_storage(line)[source]¶
storage [ACTION] [BACKEND_NAME]
Manipulation of a backend storage. :rtype:
int
cat display content of the storage
edit edit the storage
flush flush storage
- do_backends(line)[source]¶
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_logging(line)[source]¶
logging [LEVEL]
Set logging level.
Availables: debug, info, warning, error. * quiet is an alias for error * default is an alias for warning
- do_condition(line)[source]¶
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)[source]¶
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_formatter(line)[source]¶
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_select(line)[source]¶
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.
- do_ls(*args, **kwargs)[source]¶
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_cd(line)[source]¶
cd [PATH]
Follow a path. “..” is a special case and goes up one directory. “” is a special case and goes home.
- all_collections()[source]¶
Get all objects that are collections: regular objects and fake dumb objects.
- obj_to_filename(obj, dest=None, default=None)[source]¶
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:
None
)default (str) – default file mask (if not given, this is ‘{id}-{title}.{ext}’) (default:
None
)
- Return type: