diff sat_frontends/tools/css_color.py @ 2624:56f94936df1e

code style reformatting using black
author Goffi <goffi@goffi.org>
date Wed, 27 Jun 2018 20:14:46 +0200
parents 26edcf3a30eb
children 003b8b4b56a7
line wrap: on
line diff
--- a/sat_frontends/tools/css_color.py	Wed Jun 27 07:51:29 2018 +0200
+++ b/sat_frontends/tools/css_color.py	Wed Jun 27 20:14:46 2018 +0200
@@ -18,6 +18,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 from sat.core.log import getLogger
+
 log = getLogger(__name__)
 
 
@@ -167,7 +168,7 @@
     u"wheat": u"f5deb3",
     u"whitesmoke": u"f5f5f5",
     u"yellowgreen": u"9acd32",
-    u"rebeccapurple": u"663399"
+    u"rebeccapurple": u"663399",
 }
 DEFAULT = u"000000"
 
@@ -185,23 +186,23 @@
         If value can't be parsed, a warning message is logged, and DEFAULT is returned
     """
     raw_value = raw_value.strip().lower()
-    if raw_value.startswith(u'#'):
+    if raw_value.startswith(u"#"):
         # we have a hexadecimal value
         str_value = raw_value[1:]
-        if len(raw_value) in (3,4):
-            str_value = u''.join([2*v for v in str_value])
-    elif raw_value.startswith(u'rgb'):
-        left_p = raw_value.find(u'(')
-        right_p = raw_value.find(u')')
-        rgb_values = [v.strip() for v in raw_value[left_p+1:right_p].split(',')]
-        expected_len = 4 if raw_value.startswith(u'rgba') else 3
+        if len(raw_value) in (3, 4):
+            str_value = u"".join([2 * v for v in str_value])
+    elif raw_value.startswith(u"rgb"):
+        left_p = raw_value.find(u"(")
+        right_p = raw_value.find(u")")
+        rgb_values = [v.strip() for v in raw_value[left_p + 1 : right_p].split(",")]
+        expected_len = 4 if raw_value.startswith(u"rgba") else 3
         if len(rgb_values) != expected_len:
             log.warning(u"incorrect value: {}".format(raw_value))
             str_value = DEFAULT
         else:
             int_values = []
             for rgb_v in rgb_values:
-                p_idx = rgb_v.find(u'%')
+                p_idx = rgb_v.find(u"%")
                 if p_idx == -1:
                     # base 10 value
                     try:
@@ -222,8 +223,8 @@
                     except ValueError:
                         log.warning(u"invalid percent value: {}".format(rgb_v))
                         int_values.append(0)
-            str_value = u''.join([u"{:02x}".format(v) for v in int_values])
-    elif raw_value.startswith(u'hsl'):
+            str_value = u"".join([u"{:02x}".format(v) for v in int_values])
+    elif raw_value.startswith(u"hsl"):
         log.warning(u"hue-saturation-lightness not handled yet")  # TODO
         str_value = DEFAULT
     else:
@@ -236,4 +237,9 @@
     if as_string:
         return str_value
     else:
-        return tuple([int(str_value[i]+str_value[i+1], 16) for i in xrange(0, len(str_value), 2)])
+        return tuple(
+            [
+                int(str_value[i] + str_value[i + 1], 16)
+                for i in xrange(0, len(str_value), 2)
+            ]
+        )