From 486e00a3edc22f1fc6ac57ea88d4b6e3f306df2c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 2 Aug 2010 12:35:32 +0000 Subject: [PATCH] py addons: much faster scanning of addons by only parsing the dictionary rather then the entire file. --- release/scripts/ui/space_userpref.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/release/scripts/ui/space_userpref.py b/release/scripts/ui/space_userpref.py index cc95b49f41d..30d84577b3d 100644 --- a/release/scripts/ui/space_userpref.py +++ b/release/scripts/ui/space_userpref.py @@ -842,12 +842,23 @@ class USERPREF_PT_addons(bpy.types.Panel): if 1: # fake module importing - def fake_module(mod_name, mod_path, speedy=False): - print("fake_module", mod_name, mod_path) + def fake_module(mod_name, mod_path, speedy=True): + if bpy.app.debug: + print("fake_module", mod_name, mod_path) import ast ModuleType = type(ast) if speedy: - pass + lines = [] + line_iter = iter(open(mod_path, "r")) + l = "" + while not l.startswith("bl_addon_info"): + l = line_iter.readline() + while l.rstrip(): + lines.append(l) + l = line_iter.readline() + del line_iter + data = "".join(lines) + else: data = open(mod_path, "r").read()