Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def ColorType(name, *args, **kwargs):
global color_types
dtype = numpy.dtype(kwargs.pop('dtype', numpy.uint8))
if name not in color_types[dtype.name]:
channels = split_abbreviations(name)
class Color(namedtuple(name, channels)):
def __repr__(self):
return "%s(dtype=%s, %s)" % (
name, self.__class__.dtype.name,
', '.join(['%s=%s' % (i[0], i[1]) \
for i in self._asdict().items()]))
def __hex__(self):
return '0x' + "%x" * len(self) % self
def __int__(self):
return int(self.__hex__(), 16)