Reads a FITS region file and scans for any fits regions table and
    converts them into `Region` objects.

    Parameters
    ----------
    filename : str
        The file path
    errors : ``warn``, ``ignore``, ``strict``
      The error handling scheme to use for handling parsing errors.
      The default is 'strict', which will raise a `FITSRegionParserError`.
      ``warn`` will raise a `FITSRegionParserWarning`, and ``ignore`` will do nothing
      (i.e., be silent).

    Returns
    -------
    regions : list
        Python list of `regions.Region` objects.

    Examples
    --------

    >>> from astropy.utils.data import get_pkg_data_filename
    >>> from regions import read_fits_region
    >>> file_read = get_pkg_data_filename('data/region.fits',
    ...                                   package='regions.io.fits.tests')
    >>> regions = read_fits_region(file_read)

def read_fits_region(filename, errors='strict'):
    """
    Reads a FITS region file and scans for any fits regions table and
    converts them into `Region` objects.

    Parameters
    ----------
    filename : str
        The file path
    errors : ``warn``, ``ignore``, ``strict``
      The error handling scheme to use for handling parsing errors.
      The default is 'strict', which will raise a `FITSRegionParserError`.
      ``warn`` will raise a `FITSRegionParserWarning`, and ``ignore`` will do nothing
      (i.e., be silent).

    Returns
    -------
    regions : list
        Python list of `regions.Region` objects.

    Examples
    --------

    >>> from astropy.utils.data import get_pkg_data_filename
    >>> from regions import read_fits_region
    >>> file_read = get_pkg_data_filename('data/region.fits',
    ...                                   package='regions.io.fits.tests')
    >>> regions = read_fits_region(file_read)

    """
    regions = []

    hdul = fits.open(filename)

    for hdu in hdul:
        if hdu.name == 'REGION':
            table = Table.read(hdu)
            wcs = WCS(hdu.header, keysel=['image', 'binary', 'pixel'])
            regions_list = FITSRegionParser(table, errors).shapes.to_regions()
            for reg in regions_list:
                regions.append(reg.to_sky(wcs))

    return regions