diff options
| author | yo mama <pepper@scannerjammer.com> | 2015-09-21 14:20:13 -0700 |
|---|---|---|
| committer | yo mama <pepper@scannerjammer.com> | 2015-09-21 14:20:13 -0700 |
| commit | b29b0ec5f11dd66434cbdfba5287c4777d7f8ac9 (patch) | |
| tree | f02f45661bdab855d8392e14ba6448546586bf37 /lib/Param/Color | |
| parent | 8f2230b7c866320e3839d6812b98b8370a7ec5d9 (diff) | |
new file structure
Diffstat (limited to 'lib/Param/Color')
| -rw-r--r-- | lib/Param/Color/.__init__.py | 0 | ||||
| -rw-r--r-- | lib/Param/Color/__init__.py | 17 |
2 files changed, 17 insertions, 0 deletions
diff --git a/lib/Param/Color/.__init__.py b/lib/Param/Color/.__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/lib/Param/Color/.__init__.py diff --git a/lib/Param/Color/__init__.py b/lib/Param/Color/__init__.py new file mode 100644 index 0000000..9163338 --- /dev/null +++ b/lib/Param/Color/__init__.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)) |
