diff options
author | Ian Thompson <quornian@googlemail.com> | 2008-07-15 16:55:20 +0400 |
---|---|---|
committer | Ian Thompson <quornian@googlemail.com> | 2008-07-15 16:55:20 +0400 |
commit | 9037159d7a5d2e114174e77ca1e763c68de14b44 (patch) | |
tree | 749040a934a747a4860c7833035165671b0141c5 /release/scripts/textplugin_imports.py | |
parent | aeb4d0c631537d93de084301cac6a5dc981b6655 (diff) |
Text plugin script updates: Better error handling, variable parsing, token caching for repeat parsing of the same document. Fixed joining of multiline statements and context detection.
Diffstat (limited to 'release/scripts/textplugin_imports.py')
-rw-r--r-- | release/scripts/textplugin_imports.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/release/scripts/textplugin_imports.py b/release/scripts/textplugin_imports.py index af335eb5418..1773427bb01 100644 --- a/release/scripts/textplugin_imports.py +++ b/release/scripts/textplugin_imports.py @@ -13,7 +13,7 @@ try: import bpy, sys from BPyTextPlugin import * OK = True -except: +except ImportError: pass def main(): @@ -21,7 +21,7 @@ def main(): line, c = current_line(txt) # Check we are in a normal context - if get_context(line, c) != 0: + if get_context(txt) != 0: return pos = line.rfind('from ', 0, c) @@ -30,7 +30,7 @@ def main(): if pos == -1: # Check instead for straight 'import' pos2 = line.rfind('import ', 0, c) - if pos2 != -1 and pos2 == c-7: + 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.sort(cmp = suggest_cmp) txt.suggest(items, '') @@ -54,7 +54,7 @@ def main(): between = line[pos+5:pos2-1].strip() try: mod = get_module(between) - except: + except ImportError: print 'Module not found:', between return |