Skip to content

path

is_abs_or_url

is_abs_or_url(path)

Check whether a path is absolute or URL-based.

Source code in ezdag/path.py
14
15
16
17
18
def is_abs_or_url(path: str) -> bool:
    """Check whether a path is absolute or URL-based."""
    if os.path.isabs(path):
        return True
    return "://" in str(path)

normalize

normalize(path, basename=False)

Selectively return the path's basename based on a condition.

Source code in ezdag/path.py
21
22
23
24
25
26
def normalize(path: str, basename: Union[bool, Callable[[str], bool]] = False) -> str:
    """Selectively return the path's basename based on a condition."""
    if (callable(basename) and basename(path)) or basename is True:
        return os.path.basename(path)
    else:
        return path