[Bf-committers] importing bl_info
hi I'm trying to import the bl_info and use it's data as a dictionary in my script i can't find a good way to do that! i started a BA thread and no good response was there is there an API i could use, can anyone help? thanks in advance :) Regards Yousef Harfoush ba...@msn.com ___ Bf-committers mailing list Bf-committers@blender.org http://lists.blender.org/mailman/listinfo/bf-committers
Re: [Bf-committers] importing bl_info
With bl_info - you probably want to load it without running any blender code (importing bpy for eg). check on addon_utils.py, fake_module(). This returns an empty module with only bl_info attribute attached. Originally we imported the addon but now it uses pythons 'ast' module to get the dict without running the code. On Fri, Apr 27, 2012 at 7:18 AM, Yousef Hurfoush ba...@msn.com wrote: hi I'm trying to import the bl_info and use it's data as a dictionary in my script i can't find a good way to do that! i started a BA thread and no good response was there is there an API i could use, can anyone help? thanks in advance :) Regards Yousef Harfoush ba...@msn.com ___ Bf-committers mailing list Bf-committers@blender.org http://lists.blender.org/mailman/listinfo/bf-committers -- - Campbell ___ Bf-committers mailing list Bf-committers@blender.org http://lists.blender.org/mailman/listinfo/bf-committers
Re: [Bf-committers] importing bl_info
With bl_info - you probably want to load it without running any blender code (importing bpy for eg). check on addon_utils.py, fake_module(). thanks, i checked it, and it does the same almost :) as my script here: http://www.pasteall.org/31285/python so in the end, no clean way to do it. Regards Yousef Harfoush ba...@msn.com ___ Bf-committers mailing list Bf-committers@blender.org http://lists.blender.org/mailman/listinfo/bf-committers
Re: [Bf-committers] importing bl_info
On Fri, Apr 27, 2012 at 2:29 PM, Yousef Hurfoush ba...@msn.com wrote: With bl_info - you probably want to load it without running any blender code (importing bpy for eg). check on addon_utils.py, fake_module(). thanks, i checked it, and it does the same almost :) as my script here: http://www.pasteall.org/31285/python so in the end, no clean way to do it. Regards Yousef Harfoush ba...@msn.com Wouldn't say that - IMHO using AST is clean enough, checked your code and while its doing roughly the same thing by scanning for bl_info, but its using eval() which means someone could create a malicious bl_info that runs code on your system. You can avoid scanning for bl_info with ast, just load the python file data and extract the dict (without execution), when fake_module(..., speedy=False), this is what happens, it just turned out to be faster to only parse the file header. ___ Bf-committers mailing list Bf-committers@blender.org http://lists.blender.org/mailman/listinfo/bf-committers