MCPcopy Create free account
hub / github.com/pallets/quart / locate_app

Function locate_app

src/quart/cli.py:183–200  ·  view source on GitHub ↗
(module_name: str, app_name: str)

Source from the content-addressed store, hash-verified

181
182
183def locate_app(module_name: str, app_name: str) -> Quart | None:
184 try:
185 module = import_module(module_name)
186 except ImportError:
187 # Reraise the ImportError if it occurred within the imported module.
188 # Determine this by checking whether the trace has a depth > 1.
189 if sys.exc_info()[2].tb_next:
190 raise NoAppException(
191 f"While importing {module_name!r}, an ImportError was"
192 f" raised:\n\n{traceback.format_exc()}"
193 ) from None
194 else:
195 raise NoAppException(f"Could not import {module_name!r}.") from None
196 else:
197 if app_name is None:
198 return find_best_app(module)
199 else:
200 return find_app_by_string(module, app_name)
201
202
203def prepare_import(path: str) -> str:

Callers 1

load_appMethod · 0.85

Calls 3

NoAppExceptionClass · 0.85
find_best_appFunction · 0.85
find_app_by_stringFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…