[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [27717] trunk/blender/release/scripts/ keyingsets/keyingsets_utils.py: replace exceptions with getattr() fallback

Campbell Barton ideasman42 at gmail.com
Wed Mar 24 16:17:11 CET 2010


Revision: 27717
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=27717
Author:   campbellbarton
Date:     2010-03-24 16:17:11 +0100 (Wed, 24 Mar 2010)

Log Message:
-----------
replace exceptions with getattr() fallback

Modified Paths:
--------------
    trunk/blender/release/scripts/keyingsets/keyingsets_utils.py

Modified: trunk/blender/release/scripts/keyingsets/keyingsets_utils.py
===================================================================
--- trunk/blender/release/scripts/keyingsets/keyingsets_utils.py	2010-03-24 15:08:15 UTC (rev 27716)
+++ trunk/blender/release/scripts/keyingsets/keyingsets_utils.py	2010-03-24 15:17:11 UTC (rev 27717)
@@ -57,14 +57,10 @@
     # try to get the animation data associated with the closest 
     # ID-block to the data (neither of which may exist/be easy to find)
     id_block = data.id_data
-    try:
-        adt = id_block.animation_data
-    except:
-        # there isn't any animation data available 
-        return;
-        
+    adt = getattr(id_block, "animation_data", None)
+
     # there must also be an active action...
-    if adt.action is None:
+    if adt is None or adt.action is None:
         return;
         
     # for each F-Curve, include an path to key it
@@ -89,14 +85,11 @@
     else:
         # get the path to the ID-block
         path = data.path_to_id()
+
+        # try to use the name of the data element to group the F-Curve
+        # else fallback on the KeyingSet name
+        grouping = getattr(data, "name", None)
         
-        try:
-            # try to use the name of the data element to group the F-Curve
-            grouping = data.name
-        except:
-            # fallback on the KeyingSet name
-            grouping = None;
-        
     # return the ID-block and the path
     return id_block, path, grouping
 





More information about the Bf-blender-cvs mailing list