From 5a67a9766d3c797c359c855a1010603e0bbf6f46 Mon Sep 17 00:00:00 2001 From: aurium Date: Fri, 2 Oct 2009 14:42:58 +0000 Subject: [PATCH] more friendly usage for simplestyle: no more test for style attribute or type conversion on user code. --- share/extensions/simplestyle.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/share/extensions/simplestyle.py b/share/extensions/simplestyle.py index 4dcfd1aba..e312d3cef 100755 --- a/share/extensions/simplestyle.py +++ b/share/extensions/simplestyle.py @@ -173,10 +173,13 @@ svgcolors={ def parseStyle(s): """Create a dictionary from the value of an inline style attribute""" - return dict([i.split(":") for i in s.split(";") if len(i)]) + if s is None: + return {} + else: + return dict([i.split(":") for i in s.split(";") if len(i)]) def formatStyle(a): """Format an inline style attribute from a dictionary""" - return ";".join([":".join(i) for i in a.iteritems()]) + return ";".join([att+":"+str(val) for att,val in a.iteritems()]) def isColor(c): """Determine if its a color we can use. If not, leave it unchanged.""" if c.startswith('#') and (len(c)==4 or len(c)==7): -- 2.30.2