inherit from Unicode

pull/37/head
Sylvain Corlay 11 years ago
parent 19768ba7a3
commit 5c0a797813

@ -17,13 +17,12 @@ _color_names = ['aliceblue', 'antiquewhite', 'aqua', 'aquamarine', 'azure', 'bei
_color_re = re.compile(r'#[a-fA-F0-9]{3}(?:[a-fA-F0-9]{3})?$')
class Color(traitlets._CoercedString):
class Color(traitlets.Unicode):
"""A string holding a valid HTML color such as 'blue', '#060482', '#A80'"""
info_text = 'a valid HTML color'
def validate(self, obj, value):
value = self._coerce_str(obj, value)
if value.lower() in _color_names or _color_re.match(value):
return value
self.error(obj, value)
self.error(obj, value)

Loading…
Cancel
Save