Revision: 7186
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7186&view=rev
Author:   jdh2358
Date:     2009-06-06 14:16:40 +0000 (Sat, 06 Jun 2009)

Log Message:
-----------
added a properties method to the artist and inspector to return a dict mapping 
property name -> value; see sf feature request 2792183

Modified Paths:
--------------
    trunk/matplotlib/lib/matplotlib/artist.py

Modified: trunk/matplotlib/lib/matplotlib/artist.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/artist.py   2009-06-06 13:26:49 UTC (rev 
7185)
+++ trunk/matplotlib/lib/matplotlib/artist.py   2009-06-06 14:16:40 UTC (rev 
7186)
@@ -672,6 +672,12 @@
         self.pchanged()
 
 
+    def properties(self):
+        """
+        return a dictionary mapping property name -> value for all Artist props
+        """
+        return ArtistInspector(self).properties()
+
     def set(self, **kwargs):
         """
         A tkstyle set command, pass *kwargs* to set properties
@@ -876,6 +882,7 @@
         return ':meth:`%s <%s>`%s' % (s, target, aliases)
 
 
+
     def pprint_setters(self, prop=None, leadingspace=2):
         """
         If *prop* is *None*, return a list of strings of all settable properies
@@ -954,24 +961,39 @@
             lines.append('%s%s: %s' %(pad, name, accepts))
         return lines
 
-    def pprint_getters(self):
+
+    def properties(self):
         """
-        Return the getters and actual values as list of strings.
+        return a dictionary mapping property name -> value
         """
-
         o = self.oorig
         getters = [name for name in dir(o)
                    if name.startswith('get_')
                    and callable(getattr(o, name))]
         #print getters
         getters.sort()
-        lines = []
+        d = dict()
         for name in getters:
             func = getattr(o, name)
             if self.is_alias(func): continue
 
             try: val = func()
             except: continue
+            else: d[name[4:]] = val
+
+        return d
+
+    def pprint_getters(self):
+        """
+        Return the getters and actual values as list of strings.
+        """
+
+        d = self.properties()
+        names = d.keys()
+        names.sort()
+        lines = []
+        for name in names:
+            val = d[name]
             if getattr(val, 'shape', ()) != () and len(val)>6:
                 s = str(val[:6]) + '...'
             else:


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises 
looking to deploy the next generation of Solaris that includes the latest 
innovations from Sun and the OpenSource community. Download a copy and 
enjoy capabilities such as Networking, Storage and Virtualization. 
Go to: http://p.sf.net/sfu/opensolaris-get
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to