<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_colormap(name="cfastie", format="pil"):
 """ Return Pillow or GDAL compatible colormap array. Attributes name : str, optional Colormap name (default: cfastie) format: str, optional Compatiblity library, should be "pil" or "gdal" (default: pil). Returns ------- colormap : list or numpy.array Color map list in a Pillow friendly format more info: http://pillow.readthedocs.io/en/3.4.x/reference/Image.html#PIL.Image.Image.putpalette or Color map array in GDAL friendly format """

    cmap_file = os.path.join(os.path.dirname(__file__), "cmap", "{0}.txt".format(name))
    with open(cmap_file) as cmap:
        lines = cmap.read().splitlines()
        colormap = [
            list(map(int, line.split())) for line in lines if not line.startswith("#")
        ][1:]

    cmap = list(np.array(colormap).flatten())
    if format.lower() == "pil":
        return cmap
    elif format.lower() == "gdal":
        return np.array(list(_chunks(cmap, 3)))
    else:
        raise Exception("Unsupported {} colormap format".format(format))