diff options
author | Ian Thompson <quornian@googlemail.com> | 2008-07-16 14:33:48 +0400 |
---|---|---|
committer | Ian Thompson <quornian@googlemail.com> | 2008-07-16 14:33:48 +0400 |
commit | cc89221a2461e289edb380922d9f53566dc2a9eb (patch) | |
tree | 6102593c71c00f67516aed27f397cb35196fd727 /release/scripts/textplugin_imports.py | |
parent | 512eec04aa239d49ea655151cdd34ba5d754c466 (diff) |
Previously relying on import to run scripts didn't work every time and was not the right way to do it. Also fixed a problem with 'import *' not working and added the sys.modules list to the import suggestion list with a timed update.
Diffstat (limited to 'release/scripts/textplugin_imports.py')
-rw-r--r-- | release/scripts/textplugin_imports.py | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/release/scripts/textplugin_imports.py b/release/scripts/textplugin_imports.py index 1773427bb01..978efeb2c49 100644 --- a/release/scripts/textplugin_imports.py +++ b/release/scripts/textplugin_imports.py @@ -31,13 +31,13 @@ def main(): # Check instead for straight 'import' pos2 = line.rfind('import ', 0, c) if pos2 != -1 and (pos2 == c-7 or (pos2 < c-7 and line[c-2]==',')): - items = [(m, 'm') for m in sys.builtin_module_names] + items = [(m, 'm') for m in get_modules()] items.sort(cmp = suggest_cmp) txt.suggest(items, '') # Immediate 'from' before cursor elif pos == c-5: - items = [(m, 'm') for m in sys.builtin_module_names] + items = [(m, 'm') for m in get_modules()] items.sort(cmp = suggest_cmp) txt.suggest(items, '') @@ -60,12 +60,10 @@ def main(): items = [('*', 'k')] for (k,v) in mod.__dict__.items(): - if is_module(v): t = 'm' - elif callable(v): t = 'f' - else: t = 'v' - items.append((k, t)) + items.append((k, type_char(v))) items.sort(cmp = suggest_cmp) txt.suggest(items, '') -if OK: +# Check we are running as a script and not imported as a module +if __name__ == "__main__" and OK: main() |