read_crtf

regions.read_crtf(filename, errors='strict')[source]

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 CRTFRegionParserError. warn will raise a CRTFRegionParserWarning, and ignore will do nothing (i.e., be silent).

Returns:
regions : list

Python list of 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].visual)
{'color': 'blue'}