def normalize_path(path_or_f):
    """
    Verifies that a file exists at a given path and that the file has a
    known extension type.

    :Parameters:
        path_or_f : `str` | `file`
            the path to a dump file or a file handle

    """
    if hasattr(path_or_f, "read"):
        return path_or_f
    else:
        path = path_or_f

    path = os.path.expanduser(path)

    # Check if exists and is a file
    if os.path.isdir(path):
        raise IsADirectoryError("Is a directory: {0}".format(path))
    elif not os.path.isfile(path):
        raise FileNotFoundError("No such file: {0}".format(path))

    _, extension = extract_extension(path)

    if extension not in FILE_READERS:
        raise FileTypeError("Extension {0} is not supported."
                            .format(repr(extension)))

    return path
def normalize_path ( path_or_f ) : if hasattr ( path_or_f , "read" ) : return path_or_f else : path = path_or_f path = os . path . expanduser ( path ) if os . path . isdir ( path ) : raise IsADirectoryError ( "Is a directory: {0}" . format ( path ) ) elif not os . path . isfile ( path ) : raise FileNotFoundError ( "No such file: {0}" . format ( path ) ) _ , extension = extract_extension ( path ) if extension not in FILE_READERS : raise FileTypeError ( "Extension {0} is not supported." . format ( repr ( extension ) ) ) return path
Verifies that a file exists at a given path and that the file has a
    known extension type.

    :Parameters:
        path_or_f : `str` | `file`
            the path to a dump file or a file handle