diff options
| author | yo mama <pepper@scannerjammer.com> | 2015-09-23 23:57:55 -0700 |
|---|---|---|
| committer | yo mama <pepper@scannerjammer.com> | 2015-09-23 23:57:55 -0700 |
| commit | dd7d9847767361e0dfeac23ef88bb366aa99e164 (patch) | |
| tree | 9a3a29c1824885512e37a0adadb48152c3030fd2 /lib/param/color.py | |
| parent | 5c982ed500b51f5b8d911e5a5adec10ac2d31d2e (diff) | |
renamed modules
Diffstat (limited to 'lib/param/color.py')
| -rw-r--r-- | lib/param/color.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/param/color.py b/lib/param/color.py new file mode 100644 index 0000000..5293642 --- /dev/null +++ b/lib/param/color.py @@ -0,0 +1,17 @@ +from param import Param +import re +class ParamColor(Param): + def __init__(self, value, classname=""): + super(ParamColor, self).__init__(classname=classname) + try: + self.value = self._color_sanitize(value) + except Exception as e: + self.err_warn("Unable to sanitize the color: %s" % str(value)) + self.err_warn(str(e)) + def _color_sanitize(self, s): + if s == "": + return "transparent" + if re.match('(rgba?\([0-9]+,[0-9]+,[0-9]+\))|([a-zA-Z]+)|(\#[A-Ha-h0-9]+)', s): + return s.replace(' ', ''); + else: + self.err_warn("Not a color: {}\n".format(s)) |
