[reportlab-users] [patch] linecharts.py: allow labelFmt to be
'callable'
Gael Chardon
gael.dev at 4now.net
Mon Sep 25 04:51:10 EDT 2006
Hello,
hereafter a little fix for linecharts.py.
This patch replace the FunctionType test by a 'callable' test like in
barcharts.py. User can now set labelFmt to a class method and not only
global function.
Regards.
--
Gael Chardon
-------------- next part --------------
Index: linecharts.py
===================================================================
--- linecharts.py (revision 2971)
+++ linecharts.py (working copy)
@@ -248,10 +248,10 @@
labelText = self.lineLabelArray[rowNo][colNo]
else:
labelText = labelFmt % labelValue
- elif type(labelFmt) is FunctionType:
- labelText = labelFmt(labelValue)
elif isinstance(labelFmt, Formatter):
labelText = labelFmt(labelValue)
+ elif callable(labelFmt):
+ labelText = labelFmt(labelValue)
else:
msg = "Unknown formatter type %s, expected string or function"
raise Exception, msg % labelFmt
More information about the reportlab-users
mailing list