Skip to content

get_app_path

faststream.cli.utils.imports.get_app_path #

get_app_path(app: str) -> Tuple[Path, str]

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".

Note

The above docstring is autogenerated by docstring-gen library (https://docstring-gen.airt.ai)

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".
    !!! note

        The above docstring is autogenerated by docstring-gen library (https://docstring-gen.airt.ai)
    """
    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

Last update: 2023-11-13