def _path_has_ok_chars(path):
    """
    Validate path for invalid characters.
    :param path: str possible filesystem path
    :return: path if it was ok otherwise raises error
    """
    basename = os.path.basename(path)
    if any([bad_char in basename for bad_char in INVALID_PATH_CHARS]):
            raise argparse.ArgumentTypeError("{} contains invalid characters for a directory.".format(path))
    return path
Validate path for invalid characters.
    :param path: str possible filesystem path
    :return: path if it was ok otherwise raises error