def parse_colormap(colormap_location, verbose):
    
    try:
        if verbose:
            print "Reading color map:", colormap_location
        colormap_file = open(colormap_location,'r')
        dom = xml.dom.minidom.parse(colormap_file)
        colormap_file.close()
    except IOError:
        print "Accessing URL", colormap_location
        try:
            dom = xml.dom.minidom.parse(urllib.urlopen(colormap_location))
        except:
            msg = "URL " + colormap_location / " is not accessible"
            print >> sys.stderr, msg
            raise Exception(msg)

        
#     colormap_element = dom.getElementsByTagName("ColorMap")[0]
#     try:
#         units = colormap_element.attributes['units'].value
#     except KeyError:
#         units = None
#     if verbose:
#         print "ColorMap units:", units
    
    style = "discrete"
    colormap_entries = []
    colormapentry_elements = dom.getElementsByTagName("ColorMapEntry")
    for colormapentry in colormapentry_elements:
        rgb = colormapentry.attributes['rgb'].value
        red, green, blue = rgb.split(',')
        try:
            value = colormapentry.attributes['value'].value
            if "(" in value or "[" in value:
                style = "range"
        except KeyError:
            value = None
            style = "classification"
        try:
            transparent = True if colormapentry.attributes['transparent'].value.lower() == 'true' else False
        except KeyError:
            transparent = False
        try:
            source_value = colormapentry.attributes['sourceValue'].value
        except KeyError:
            source_value = value
        try:
            label = colormapentry.attributes['label'].value
        except KeyError:
            label = value
        try:
            nodata = True if colormapentry.attributes['nodata'].value.lower() == 'true' else False
        except KeyError:
            nodata = False
        
        colormap_entries.append(ColorMapEntry(red, green , blue, transparent, source_value, value, label, nodata))
        
    colormap = ColorMap(None, colormap_entries, style)
    if verbose:
        print "ColorMap style:", style
        print colormap
    
    return colormap
    

#-------------------------------------------------------------------------------
dataset/ETHPy150Open nasa-gibs/onearth/src/layer_config/bin/oe_generate_empty_tile.py/parse_colormap/operator `+` -> `/`