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

Class ScriptInfo

src/quart/cli.py:232–276  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

230
231
232class ScriptInfo:
233 def __init__(
234 self,
235 app_import_path: str | None = None,
236 create_app: Callable[..., Quart] | None = None,
237 set_debug_flag: bool = True,
238 ) -> None:
239 self.app_import_path = app_import_path
240 self.create_app = create_app
241 self.data: dict[Any, Any] = {}
242 self.set_debug_flag = set_debug_flag
243 self._loaded_app: Quart | None = None
244
245 def load_app(self) -> Quart:
246 if self._loaded_app is not None:
247 return self._loaded_app
248
249 if self.create_app is not None:
250 app = self.create_app()
251 else:
252 if self.app_import_path:
253 path, name = (
254 re.split(r":(?![\\/])", self.app_import_path, maxsplit=1) + [None]
255 )[:2]
256 import_name = prepare_import(path)
257 app = locate_app(import_name, name)
258 else:
259 import_name = prepare_import("app.py")
260 app = locate_app(import_name, None)
261
262 if not app:
263 raise NoAppException(
264 "Could not locate a Quart application. Use the"
265 " 'quart --app' option, 'QUART_APP' environment"
266 " variable, or an 'app.py' file in the"
267 " current directory."
268 )
269
270 if self.set_debug_flag:
271 # Update the app's debug flag through the descriptor so that
272 # other values repopulate as well.
273 app.debug = get_debug_flag()
274
275 self._loaded_app = app
276 return app
277
278
279pass_script_info = click.make_pass_decorator(ScriptInfo, ensure=True)

Callers 3

make_contextMethod · 0.85
invokeMethod · 0.85

Calls

no outgoing calls

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…