from pathlib import Path


def _gen_outdir(outdir):
    """
    Coerces `outdir` to `pathlib.Path` and creates it, if it doesn't exist

    Parameters
    ----------
    outdir : str
        Path to desired output directory

    Returns
    -------
    outdir : pathlib.Path
        Path to desired output directory
    """
    outdir = Path(outdir).expanduser().resolve()
    outdir.mkdir(exist_ok=True)

    return outdir