Get the application path.
PARAMETER | DESCRIPTION |
app | The name of the application in the format "module:app_name". TYPE: str |
RETURNS | DESCRIPTION |
Tuple[Path, str] | Tuple[Path, str]: A tuple containing the path to the module and the name of the application. |
RAISES | DESCRIPTION |
ValueError | If the given app is not in the format "module:app_name". |
Source code in faststream/cli/utils/imports.py
| def get_app_path(app: str) -> Tuple[Path, str]:
"""Get the application path.
Args:
app (str): The name of the application in the format "module:app_name".
Returns:
Tuple[Path, str]: A tuple containing the path to the module and the name of the application.
Raises:
ValueError: If the given app is not in the format "module:app_name".
"""
if ":" not in app:
raise ValueError(f"{app} is not a FastStream")
module, app_name = app.split(":", 2)
mod_path = Path.cwd()
for i in module.split("."):
mod_path = mod_path / i
return mod_path, app_name
|