[Python-modules-commits] [python-mplexporter] 111/135: PEP8 and better error handling

Wolfgang Borgert debacle at moszumanska.debian.org
Tue Sep 23 21:19:10 UTC 2014


This is an automated email from the git hooks/post-receive script.

debacle pushed a commit to branch master
in repository python-mplexporter.

commit 99c637cb5cff112831203d606e3bc71b941a3da5
Author: John Eppley <jmeppley at gmail.com>
Date:   Wed Mar 26 13:47:16 2014 -0400

    PEP8 and better error handling
---
 mplexporter/exporter.py | 26 +++++++++++++++-----------
 mplexporter/utils.py    |  5 ++---
 2 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/mplexporter/exporter.py b/mplexporter/exporter.py
index 9911247..81bae60 100644
--- a/mplexporter/exporter.py
+++ b/mplexporter/exporter.py
@@ -157,17 +157,21 @@ class Exporter(object):
             # force a large zorder so it appears on top
             child.set_zorder(1E6 + child.get_zorder())
 
-            # What kind of object...
-            if isinstance(child, matplotlib.patches.Patch):
-                self.draw_patch(ax, child, force_trans=ax.transAxes)
-            elif isinstance(child, matplotlib.text.Text):
-                if not (child is legend.get_children()[-1]
-                        and child.get_text() == 'None'):
-                    self.draw_text(ax, child, force_trans=ax.transAxes)
-            elif isinstance(child, matplotlib.lines.Line2D):
-                self.draw_line(ax, child, force_trans=ax.transAxes)
-            else:
-                warnings.warn("Legend element %s not impemented" & child)
+            try:
+                # What kind of object...
+                if isinstance(child, matplotlib.patches.Patch):
+                    self.draw_patch(ax, child, force_trans=ax.transAxes)
+                elif isinstance(child, matplotlib.text.Text):
+                    if not (child is legend.get_children()[-1]
+                            and child.get_text() == 'None'):
+                        self.draw_text(ax, child, force_trans=ax.transAxes)
+                elif isinstance(child, matplotlib.lines.Line2D):
+                    self.draw_line(ax, child, force_trans=ax.transAxes)
+                else:
+                    warnings.warn("Legend element %s not impemented" % child)
+            except NotImplementedError:
+                warnings.warn("Legend element %s not impemented" % child)
+
 
     def draw_line(self, ax, line, force_trans=None):
         """Process a matplotlib line and call renderer.draw_line"""
diff --git a/mplexporter/utils.py b/mplexporter/utils.py
index 87f8ad0..ffb11ec 100644
--- a/mplexporter/utils.py
+++ b/mplexporter/utils.py
@@ -304,13 +304,12 @@ def iter_all_children(obj, skipContainers=False):
 
     if skipContainers is true, only childless objects are returned.
     """
-    if hasattr(obj, 'get_children') and len(obj.get_children())>0:
+    if hasattr(obj, 'get_children') and len(obj.get_children()) > 0:
         for child in obj.get_children():
             if not skipContainers:
                 yield child
             # could use `yield from` in python 3...
-            for grandchild in iter_all_children(child,
-                    skipContainers=skipContainers):
+            for grandchild in iter_all_children(child,skipContainers):
                 yield grandchild
     else:
         yield obj

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-mplexporter.git



More information about the Python-modules-commits mailing list