From d757126a196d0cfd65b01c9befbf3b03f678e48b Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Mon, 10 Sep 2007 00:06:24 +0000 Subject: Move entity type checks at loader level so that they are shared by all both icon implementations. --- (limited to 'sugar/graphics') diff --git a/sugar/graphics/icon.py b/sugar/graphics/icon.py index 4cb3044..6cb6372 100644 --- a/sugar/graphics/icon.py +++ b/sugar/graphics/icon.py @@ -51,8 +51,12 @@ class _SVGLoader(object): self._cache[file_name] = icon for entity, value in entities.items(): - xml = '' % (entity, value) - icon = re.sub('' % entity, xml, icon) + if isinstance(value, basestring): + xml = '' % (entity, value) + icon = re.sub('' % entity, xml, icon) + else: + logging.error( + 'Icon %s, entity %s is invalid.', file_name, entity) return rsvg.Handle(data=icon) @@ -376,13 +380,9 @@ class CanvasIcon(hippo.CanvasBox, hippo.CanvasItem): self.props.fill_color = value.get_fill_color() self.props.stroke_color = value.get_stroke_color() elif pspec.name == 'fill-color': - if not isinstance(value, basestring) and value is not None: - raise TypeError('fill-color must be a string, not %r' % type(value)) self._buffer.fill_color = value self.emit_paint_needed(0, 0, -1, -1) elif pspec.name == 'stroke-color': - if not isinstance(value, basestring) and value is not None: - raise TypeError('stroke-color must be a string, not %r' % type(value)) self._buffer.stroke_color = value self.emit_paint_needed(0, 0, -1, -1) elif pspec.name == 'size': -- cgit v0.9.1