3 def blank_bmp(w, h, color="white"):
4 bmp = wx.EmptyBitmap(max(w,1) , max(h,1))
8 def clear_bmp(bmp, color):
11 dc.SetBackground(wx.Brush(color))
15 # Taken and adapt from django.utils.encoding
16 class GPdf2SwfUnicodeDecodeError(UnicodeDecodeError):
17 def __init__(self, obj, *args):
19 UnicodeDecodeError.__init__(self, *args)
22 original = UnicodeDecodeError.__str__(self)
23 return '%s. You passed in %r (%s)' % (original, self.obj,
26 def force_unicode(s, encoding='utf-8', strings_only=False, errors='strict'):
28 if not isinstance(s, basestring,):
29 if hasattr(s, '__unicode__'):
33 s = unicode(str(s), encoding, errors)
34 except UnicodeEncodeError:
35 if not isinstance(s, Exception):
37 # If we get to here, the caller has passed in an Exception
38 # subclass populated with non-ASCII data without special
39 # handling to display as a string. We need to handle this
40 # without raising a further exception. We do an
41 # approximation to what the Exception's standard str()
43 s = ' '.join([force_unicode(arg, encoding, strings_only,
44 errors) for arg in s])
45 elif not isinstance(s, unicode):
46 # Note: We use .decode() here, instead of unicode(s, encoding,
47 # errors), so that if s is a SafeString, it ends up being a
48 # SafeUnicode at the end.
49 s = s.decode(encoding, errors)
50 except UnicodeDecodeError, e:
51 raise GPdf2SwfUnicodeDecodeError(s, *e.args)
52 #raise UnicodeDecodeError(*e.args)