Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
colors = palette.get('colors', None)
if isinstance(colors, (tuple, list)):
cmap = []
values = palette.get('values', None)
for idx, color in enumerate(colors):
if values is not None:
value = values[idx]
else:
value = idx / float(len(colors) - 1)
cmap.append((value, tuple(color)))
return Colormap(*cmap)
if isinstance(colors, str):
from trollimage import colormap
import copy
return copy.copy(getattr(colormap, colors))
return None