# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/07_path.ipynb.

# %% auto 0
__all__ = ['ispath', 'ispathlike', 'isdir', 'isfile', 'ishidden']

# %% ../nbs/07_path.ipynb 4
import os, pathlib
from typing import TypeGuard, Union

# %% ../nbs/07_path.ipynb 6
def ispath(x) -> TypeGuard[pathlib.Path]:
    '''Check if `x` is `pathlib.Path`.'''
    return isinstance(x, pathlib.Path)

def ispathlike(x) -> TypeGuard[Union[str, pathlib.Path, os.PathLike]]:
    '''Check if `x` is `str`, `pathlib.Path` or `os.PathLike`.'''
    return isinstance(x, (str, pathlib.Path, os.PathLike))

def isdir(x) -> TypeGuard[pathlib.Path]: 
    '''Check if `x` is `pathlib.Path` and exists.'''
    return ispathlike(x) and pathlib.Path(x).is_dir()

def isfile(x) -> TypeGuard[pathlib.Path]: 
    '''Check if `x` is `pathlib.Path` and exists.'''
    return ispathlike(x) and pathlib.Path(x).is_file()

def ishidden(x) -> TypeGuard[pathlib.Path]: 
    '''Check if `x` is `pathlib.Path` and is a hidden file or directory.'''
    pname = pathlib.Path(x).name
    return ispathlike(x) and (pname.startswith('.') or pname.startswith('_'))
