(module_name: str, app_name: str)
| 181 | |
| 182 | |
| 183 | def 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 | |
| 203 | def prepare_import(path: str) -> str: |
no test coverage detected
searching dependent graphs…