dabo Commit
Revision 2914
Date: 2007-03-14 17:05:53 -0700 (Wed, 14 Mar 2007)
Author: Ed
Trac: http://svn.dabodev.com/trac/dabo/changeset/2914

Changed:
U   trunk/dabo/dObject.py

Log:
Updated the __repr__() method to include angle brackets and also simplify the 
displayed class names.


Diff:
Modified: trunk/dabo/dObject.py
===================================================================
--- trunk/dabo/dObject.py       2007-03-14 15:45:51 UTC (rev 2913)
+++ trunk/dabo/dObject.py       2007-03-15 00:05:53 UTC (rev 2914)
@@ -75,11 +75,26 @@
                        bc = self.__class__
                strval = "%s" % bc
                classname = strval.split("'")[1]
+               classparts = classname.split(".")
+               if ".ui.ui" in classname:
+                       # Simplify the different UI toolkits
+                       pos = classparts.index("ui")
+                       classparts.pop(pos+1)
+               # Remove the duplicate class name that happens
+               # when the class name is the same as the file.
+               while classparts[-1] == classparts[-2]:
+                       classparts.pop()
+               classname = ".".join(classparts)
+               spc = " "
                try:
-                       ret = "%s (%s)" % (self.Name, classname)
-               except:
-                       ret = classname
-               return ret
+                       nm = self.Name
+               except AttributeError:
+                       nm = ""
+               if (not nm) or (nm == "?"):
+                       # No name
+                       nm = spc = ""
+               return "<%(nm)s%(spc)s(class %(classname)s)>" % locals()
+               
 
 
        def beforeInit(self, *args, **kwargs):




_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev

Reply via email to