import fnmatch


def check_file_type(file_path, file_types):
    """
    Check file type to assert that only file with certain predefined extensions
    are checked. We currently support an extension verbatim, or regular
    expression to match the filename. For example, .* matches all hidden files,
    and *.html matches an html file.

    Args:
        - file_path   (str) : path to file.
        - file_types (list) : list of file extensions to accept.

    Returns:
        (bool) true if file type is supported else false.
    """
    ftype = "." + file_path.split(".")[-1]
    if ftype in file_types:
        return True

    # The user can also provide a regular expression
    if any(fnmatch.fnmatch(file_path, x) for x in file_types):
        return True

    # default return
    return False