Reads a CRTF region file and returns a list of region objects.

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

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

    Examples
    --------
    >>> from regions import read_crtf
    >>> from astropy.utils.data import get_pkg_data_filename
    >>> file = get_pkg_data_filename('data/CRTFgeneral.crtf', package='regions.io.crtf.tests')
    >>> regs = read_crtf(file, errors='warn')
    >>> print(regs[0])
    Region: CircleSkyRegion
    center: <SkyCoord (FK4: equinox=B1950.000, obstime=B1950.000): (ra, dec) in deg
    (273.1, -23.18333333)>
    radius: 2.3 arcsec
    >>> print(regs[0].meta)
    {'frame': 'BARY', 'corr': ['I', 'Q'], 'include': True, 'type': 'ann'}
    >>> print(regs[0].visual)
    {'color': 'blue'}

def read_crtf(filename, errors='strict'):
    """
    Reads a CRTF region file and returns a list of region objects.

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

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

    Examples
    --------
    >>> from regions import read_crtf
    >>> from astropy.utils.data import get_pkg_data_filename
    >>> file = get_pkg_data_filename('data/CRTFgeneral.crtf', package='regions.io.crtf.tests')
    >>> regs = read_crtf(file, errors='warn')
    >>> print(regs[0])
    Region: CircleSkyRegion
    center: <SkyCoord (FK4: equinox=B1950.000, obstime=B1950.000): (ra, dec) in deg
    (273.1, -23.18333333)>
    radius: 2.3 arcsec
    >>> print(regs[0].meta)
    {'frame': 'BARY', 'corr': ['I', 'Q'], 'include': True, 'type': 'ann'}
    >>> print(regs[0].visual)
    {'color': 'blue'}

    """
    with open(filename) as fh:
        if regex_begin.search(fh.readline()):
            region_string = fh.read()
            parser = CRTFParser(region_string, errors)
            return parser.shapes.to_regions()
        else:
            raise CRTFRegionParserError('Every CRTF Region must start with "#CRTF" ')