Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomeu Vizoso <tomeu@sugarlabs.org>2009-09-11 11:47:40 (GMT)
committer Tomeu Vizoso <tomeu@sugarlabs.org>2009-09-11 11:47:40 (GMT)
commit0159bc7b5243fb603f7afd12d8ff34ffacff291f (patch)
treed86372c1510a1d908a7fdb3289dd62e9815eebf2
parent8e3e7dd8ad9476a2cf7cb5ad79e8a55f9b61a9d9 (diff)
Warn when the XoColor string is invalid.
-rw-r--r--src/sugar/graphics/xocolor.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/sugar/graphics/xocolor.py b/src/sugar/graphics/xocolor.py
index 92a61a4..00238d9 100644
--- a/src/sugar/graphics/xocolor.py
+++ b/src/sugar/graphics/xocolor.py
@@ -20,6 +20,7 @@ STABLE.
"""
import random
+import logging
colors = [
['#B20008', '#FF2B34'], \
@@ -225,7 +226,16 @@ def is_valid(color_string):
class XoColor:
def __init__(self, color_string=None):
- if color_string == None or not is_valid(color_string):
+ if color_string == None:
+ randomize = True
+ elif not is_valid(color_string):
+ logging.error('Color string is not valid: %s, will generate a '
+ 'random color pair.', color_string)
+ randomize = True
+ else:
+ randomize = False
+
+ if randomize:
n = int(random.random() * (len(colors) - 1))
[self.stroke, self.fill] = colors[n]
else: