Show More
@@ -80,10 +80,15 b' def module_list(path):' | |||||
80 | pjoin = os.path.join |
|
80 | pjoin = os.path.join | |
81 | basename = os.path.basename |
|
81 | basename = os.path.basename | |
82 |
|
82 | |||
|
83 | def is_importable_file(path): | |||
|
84 | """Returns True if the provided path is a valid importable module""" | |||
|
85 | name, extension = os.path.splitext( path ) | |||
|
86 | return import_re.match(path) and py3compat.isidentifier(name) | |||
|
87 | ||||
83 | # Now find actual path matches for packages or modules |
|
88 | # Now find actual path matches for packages or modules | |
84 | folder_list = [p for p in folder_list |
|
89 | folder_list = [p for p in folder_list | |
85 | if isfile(pjoin(path, p,'__init__.py')) |
|
90 | if isfile(pjoin(path, p,'__init__.py')) | |
86 |
or import |
|
91 | or is_importable_file(p) ] | |
87 |
|
92 | |||
88 | return [basename(p).split('.')[0] for p in folder_list] |
|
93 | return [basename(p).split('.')[0] for p in folder_list] | |
89 |
|
94 |
@@ -76,4 +76,5 b' class Test_magic_run_completer(unittest.TestCase):' | |||||
76 | open(filename, 'w').close() |
|
76 | open(filename, 'w').close() | |
77 |
|
77 | |||
78 | s = set( module_completion('import foo') ) |
|
78 | s = set( module_completion('import foo') ) | |
79 |
|
|
79 | intersection = s.intersection(invalid_module_names) | |
|
80 | self.assertFalse(intersection, intersection) |
General Comments 0
You need to be logged in to leave comments.
Login now