Skip to content

files

get_file(name, path)

Validate path

Source code in systemd_py/utils/files.py
def get_file(name: str, path: Union[str, Path]) -> Path:
    """
    Validate path
    """

    if not name.endswith('.service'):
        name += '.service'

    if isinstance(path, str):
        path = Path(path)

    path = path.resolve()

    if path.is_file():
        path = path.parent

    return path / name