[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [34170] trunk/blender/release/scripts/ui/ space_userpref.py: fix for drawing addons when one of them had a syntax error or would not draw any .

Campbell Barton ideasman42 at gmail.com
Sat Jan 8 05:49:33 CET 2011


Revision: 34170
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=34170
Author:   campbellbarton
Date:     2011-01-08 04:49:33 +0000 (Sat, 08 Jan 2011)
Log Message:
-----------
fix for drawing addons when one of them had a syntax error or would not draw any.
now print the error and continue.

Modified Paths:
--------------
    trunk/blender/release/scripts/ui/space_userpref.py

Modified: trunk/blender/release/scripts/ui/space_userpref.py
===================================================================
--- trunk/blender/release/scripts/ui/space_userpref.py	2011-01-08 01:45:02 UTC (rev 34169)
+++ trunk/blender/release/scripts/ui/space_userpref.py	2011-01-08 04:49:33 UTC (rev 34170)
@@ -890,15 +890,24 @@
 
             file_mod.close()
 
-            ast_data = ast.parse(data, filename=mod_path)
+            try:
+                ast_data = ast.parse(data, filename=mod_path)
+            except:
+                print("Syntax error 'ast.parse' can't read %r" % mod_path)
+                import traceback
+                traceback.print_exc()
+                ast_data = None
+
             body_info = None
-            for body in ast_data.body:
-                if body.__class__ == ast.Assign:
-                    if len(body.targets) == 1:
-                        if getattr(body.targets[0], "id", "") == "bl_addon_info":
-                            body_info = body
-                            break
 
+            if ast_data:
+                for body in ast_data.body:
+                    if body.__class__ == ast.Assign:
+                        if len(body.targets) == 1:
+                            if getattr(body.targets[0], "id", "") == "bl_addon_info":
+                                body_info = body
+                                break
+
             if body_info:
                 mod = ModuleType(mod_name)
                 mod.bl_addon_info = ast.literal_eval(body.value)




More information about the Bf-blender-cvs mailing list