From 0159bc7b5243fb603f7afd12d8ff34ffacff291f Mon Sep 17 00:00:00 2001 From: Tomeu Vizoso Date: Fri, 11 Sep 2009 11:47:40 +0000 Subject: Warn when the XoColor string is invalid. --- 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: -- cgit v0.9.1