def IsDir(v):
    """Verify the directory exists.

    >>> IsDir()('/')
    '/'
    >>> with raises(DirInvalid, 'Not a directory'):
    ...   IsDir()(None)
    """
    try:
        if v:
            v = str(v)
            return os.path.isdir(v)
        else:
            raise DirInvalid("Not a directory")
    except TypeError:
        raise DirInvalid("Not a directory")
Verify the directory exists.

    >>> IsDir()('/')
    '/'
    >>> with raises(DirInvalid, 'Not a directory'):
    ...   IsDir()(None)