quart.cli module#
- exception quart.cli.NoAppException(message, ctx=None)#
Bases:
UsageError
- Parameters:
message (str)
ctx (Context | None)
- Return type:
None
- quart.cli.find_app_by_string(module, app_name)#
- Parameters:
module (ModuleType)
app_name (str)
- Return type:
- quart.cli.locate_app(module_name, app_name)#
- Parameters:
module_name (str)
app_name (str)
- Return type:
Quart | None
- quart.cli.prepare_import(path)#
Given a filename this will try to calculate the python path, add it to the search path and return the actual module name that is expected.
- Parameters:
path (str)
- Return type:
str
- class quart.cli.ScriptInfo(app_import_path=None, create_app=None, set_debug_flag=True)#
Bases:
object
- Parameters:
app_import_path (str | None)
create_app (Callable[..., Quart] | None)
set_debug_flag (bool)
- quart.cli.with_appcontext(fn=None)#
- Parameters:
fn (Callable | None)
- Return type:
Callable
- class quart.cli.AppGroup(name=None, commands=None, **attrs)#
Bases:
Group
This works similar to a regular click
Group
but it changes the behavior of thecommand()
decorator so that it automatically wraps the functions inwith_appcontext()
.Not to be confused with
QuartGroup
.- Parameters:
name (str | None)
commands (MutableMapping[str, Command] | Sequence[Command] | None)
attrs (Any)
- command(*args, **kwargs)#
This works exactly like the method of the same name on a regular
click.Group
but it wraps callbacks inwith_appcontext()
if it’s enabled by passingwith_appcontext=True
.- Parameters:
args (Any)
kwargs (Any)
- Return type:
Callable
- group(*args, **kwargs)#
A shortcut decorator for declaring and attaching a group to the group. This takes the same arguments as
group()
and immediately registers the created group with this group by callingadd_command()
.To customize the group class used, set the
group_class
attribute.Changed in version 8.1: This decorator can be applied without parentheses.
Changed in version 8.0: Added the
group_class
attribute.- Parameters:
args (Any)
kwargs (Any)
- Return type:
Callable
- quart.cli.get_version(ctx, param, value)#
- Parameters:
ctx (Any)
param (Any)
value (Any)
- Return type:
None
- class quart.cli.QuartGroup(add_default_commands=True, create_app=None, add_version_option=True, load_dotenv=True, set_debug_flag=True, **extra)#
Bases:
AppGroup
- Parameters:
add_default_commands (bool)
create_app (Callable[..., Quart] | None)
add_version_option (bool)
load_dotenv (bool)
set_debug_flag (bool)
extra (Any)
- get_command(ctx, name)#
Given a context and a command name, this returns a
Command
object if it exists or returnsNone
.- Parameters:
ctx (Context)
name (str)
- Return type:
Command
- list_commands(ctx)#
Returns a list of subcommand names in the order they should appear.
- Parameters:
ctx (Context)
- Return type:
list[str]
- make_context(info_name, args, parent=None, **extra)#
This function when given an info name and arguments will kick off the parsing and create a new
Context
. It does not invoke the actual command callback though.To quickly customize the context class used without overriding this method, set the
context_class
attribute.- Parameters:
info_name (str | None) – the info name for this invocation. Generally this is the most descriptive name for the script or command. For the toplevel script it’s usually the name of the script, for commands below it’s the name of the command.
args (list[str]) – the arguments to parse as list of strings.
parent (Context | None) – the parent context if available.
extra (Any) – extra keyword arguments forwarded to the context constructor.
- Return type:
Context
Changed in version 8.0: Added the
context_class
attribute.
- parse_args(ctx, args)#
Given a context and a list of arguments this creates the parser and parses the arguments, then modifies the context as necessary. This is automatically invoked by
make_context()
.- Parameters:
ctx (Context)
args (list[str])
- Return type:
list[str]
- quart.cli.load_dotenv(path=None)#
Load “dotenv” files in order of precedence to set environment variables. If an env var is already set it is not overwritten, so earlier files in the list are preferred over later files. This is a no-op if `python-dotenv`_ is not installed. .. _python-dotenv: theskumar/python-dotenv :param path: Load the file at this location instead of searching. :return:
True
if a file was loaded.- Parameters:
path (str | PathLike | None)
- Return type:
bool
- quart.cli.main()#
- Return type:
None