summaryrefslogtreecommitdiff
path: root/lib/param/color.py
diff options
context:
space:
mode:
authorPepper <pepper@scannerjammer.com>2015-09-26 22:00:15 -0400
committerPepper <pepper@scannerjammer.com>2015-09-26 22:00:15 -0400
commit0e9991e9bd5748a6d32c825e0a00a5ac15c29982 (patch)
tree7bf222228a84793f1980db61a37c060afa616541 /lib/param/color.py
parent4ebeb643da6419835e9ac3adb731e38a8ec9c7b4 (diff)
linting...
Diffstat (limited to 'lib/param/color.py')
-rw-r--r--lib/param/color.py34
1 files changed, 20 insertions, 14 deletions
diff --git a/lib/param/color.py b/lib/param/color.py
index a339b7f..1c62955 100644
--- a/lib/param/color.py
+++ b/lib/param/color.py
@@ -1,17 +1,23 @@
+"""Defines the color param type"""
from param import Param
import re
class Color(Param):
- def __init__(self, value, classname=""):
- super(Color, 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))
+ """Defines the color param type
+ Args:
+ value: the value of the color (string)
+ classname: the name of the class to which the param belongs
+ """
+ def __init__(self, value, classname=""):
+ super(Color, 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))