Skip to content

Commit f4c0ed6

Browse files
some changes to file reading
1 parent 5739504 commit f4c0ed6

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

bpython/importcompletion.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import os
3636
import sys
3737
import warnings
38+
import re
3839
from six.moves import filter
3940

4041
if py3:
@@ -134,6 +135,10 @@ def complete(cursor_offset, line):
134135

135136
def find_modules(path):
136137
"""Find all modules (and packages) for a given directory."""
138+
139+
global nameSubname
140+
nameSubname = []
141+
137142
if not os.path.isdir(path):
138143
# Perhaps a zip file
139144
return
@@ -192,8 +197,21 @@ def find_modules(path):
192197
if is_package:
193198
for subname in find_modules(pathname):
194199
if subname != "__init__":
195-
yield "%s.%s" % (name, subname)
200+
doNotAppend = False
201+
for obj in nameSubname:
202+
nam = obj[0]
203+
subnam = obj[1]
204+
if (name == nam and subname == subnam) or \
205+
any(nam in sub for sub in re.split("[.]", subname)) or \
206+
any(subname in na for na in re.split("[.]", name)):
207+
doNotAppend = True
208+
break
209+
if not doNotAppend:
210+
nameSubname.append((name, subname))
211+
yield "%s.%s" % (name, subname)
196212
yield name
213+
for obj in nameSubname:
214+
print(obj[0] + " " + obj[1])
197215

198216

199217
def find_all_modules(path=None):

0 commit comments

Comments
 (0)