Skip to content

Commit 2b96e8d

Browse files
"Used os.path.realpath to fix issue"
1 parent 8e08f3a commit 2b96e8d

5 files changed

Lines changed: 8 additions & 49 deletions

File tree

bpython/importcompletion.py

Lines changed: 6 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -201,57 +201,14 @@ def find_modules(path):
201201
continue
202202
else:
203203
if is_package:
204-
pathGood = False
205-
if useNameSubname == 2:
206-
pathGood = True
207-
208-
pathList = re.split("[/]", pathname)
209-
#print("pathL length:", len(pathList))
210-
#for pathL in pathList:
211-
#print("pathL:", pathL)
212-
213-
#I did path len - 2 because I am worried about folders like bpython/bpython
214-
# but if it is a symbolic link it will stop at bpython/bpython/bpython
215-
for folder in range(len(pathList) - 2):
216-
if pathList[folder] == pathList[len(pathList) - 1]:
217-
pathGood = False
218-
#print(pathGood)
219-
#print()
220-
elif useNameSubname == 4:
221-
pathGood = True
222-
pathReal = os.path.realpath(pathname)
223-
if len(pathReal) < len(pathname) and pathReal in pathname:
224-
#print("PathReal:", pathReal, "Path:", pathname)
225-
pathGood = False
226-
if useNameSubname == 1 or pathGood:
204+
pathGood = True
205+
pathReal = os.path.realpath(pathname)
206+
if len(pathReal) < len(pathname) and pathReal in pathname:
207+
pathGood = False
208+
if pathGood:
227209
for subname in find_modules(pathname):
228210
if subname != "__init__":
229-
#If trying the first method using name and subname
230-
if useNameSubname == 1:
231-
doNotAppend = False
232-
#print("name: ", name, " subname: ", subname)
233-
for obj in nameSubname:
234-
nam = obj[0]
235-
subnam = obj[1]
236-
#print("name: ", name, " nam: ", nam, " subname: ", subname, " subnam: ", subnam)
237-
if (name == nam and subname == subnam) or \
238-
any(name in sub for sub in re.split("[.]", subnam)):
239-
#print("Excluded: ", name, subname, "because ", nam, subnam)
240-
doNotAppend = True
241-
break
242-
#print()
243-
if not doNotAppend:
244-
nameSubname.append((name, subname))
245-
#print(name, subname)
246-
yield "%s.%s" % (name, subname)
247-
#If trying seconf methond using the pathname
248-
else:
249-
yield "%s.%s" % (name, subname)
250-
elif useNameSubname == 3:
251-
for subname in find_modules(pathname):
252-
if subname != "__init__":
253-
yield "%s.%s" % (name, subname)
254-
#print("Name: ", name)
211+
yield "%s.%s" % (name, subname)
255212
yield name
256213

257214
def find_all_modules(path=None):

importtestfolder/Left/__init__.py

Whitespace-only changes.

importtestfolder/Left/toRight

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/Users/eerichart/bpython/importtestfolder/Right

importtestfolder/Right/__init__.py

Whitespace-only changes.

importtestfolder/Right/toLeft

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/Users/eerichart/bpython/importtestfolder/Left

0 commit comments

Comments
 (0)