summaryrefslogtreecommitdiff
path: root/Param/Color
diff options
context:
space:
mode:
authoryo mama <pepper@scannerjammer.com>2015-09-15 19:39:59 -0700
committeryo mama <pepper@scannerjammer.com>2015-09-15 19:39:59 -0700
commitacc164568a215c3c5e2363855f712291b2a459e1 (patch)
treef91454aca1de19dadc61cd892a5b4fa72c7ac32d /Param/Color
parent7d0116ba389e061bd609cc999f1c993b7344cf55 (diff)
more oop
Diffstat (limited to 'Param/Color')
-rw-r--r--Param/Color/.__init__.py0
-rw-r--r--Param/Color/__init__.py18
2 files changed, 18 insertions, 0 deletions
diff --git a/Param/Color/.__init__.py b/Param/Color/.__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Param/Color/.__init__.py
diff --git a/Param/Color/__init__.py b/Param/Color/__init__.py
new file mode 100644
index 0000000..ea7895c
--- /dev/null
+++ b/Param/Color/__init__.py
@@ -0,0 +1,18 @@
+from Param import Param
+
+def ParamColor(Param):
+ def __init__(self, value, classname=""):
+ self._classname = classname
+ super(ParamColor).__init__()
+ 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))