Skip to content

Commit 347707d

Browse files
Some work on symbolic link files
1 parent f4c0ed6 commit 347707d

7 files changed

Lines changed: 126 additions & 16 deletions

File tree

bpython/importcompletion.py

Lines changed: 53 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ def find_modules(path):
139139
global nameSubname
140140
nameSubname = []
141141

142+
#global pathNameList
143+
#pathNameList = []
144+
142145
if not os.path.isdir(path):
143146
# Perhaps a zip file
144147
return
@@ -195,23 +198,57 @@ def find_modules(path):
195198
continue
196199
else:
197200
if is_package:
198-
for subname in find_modules(pathname):
199-
if subname != "__init__":
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)
201+
pathGood = True
202+
#print("pathname:", pathname)
203+
#for paths in pathNameList:
204+
#print(paths)
205+
#print("Hi")
206+
207+
#if pathname == paths:
208+
#pathGood = False
209+
#break
210+
211+
pathList = re.split("[/]", pathname)
212+
#print("pathL length:", len(pathList))
213+
#for pathL in pathList:
214+
#print("pathL:", pathL)
215+
216+
for folder in range(len(pathList)):
217+
for folderT in range(len(pathList)):
218+
#print("folder:", folder, "folderT:", folderT)
219+
#print("Pathlist Folder:", pathList[folder], "Pathlist FolderT:", pathList[folderT])
220+
if folder == folderT:
221+
continue
222+
elif pathList[folder] == pathList[folderT]:
223+
pathGood = False
224+
#print(pathGood)
225+
#print()
226+
if pathGood:
227+
#pathNameList.append(pathname)
228+
#print("PathGood len", len(pathNameList), pathname)
229+
for subname in find_modules(pathname):
230+
if subname != "__init__":
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)
212247
yield name
213248
for obj in nameSubname:
214-
print(obj[0] + " " + obj[1])
249+
#print(obj[0] + " " + obj[1])
250+
pass
251+
#print("PathNameList len:", len(pathNameList))
215252

216253

217254
def find_all_modules(path=None):
@@ -220,7 +257,7 @@ def find_all_modules(path=None):
220257
if path is None:
221258
modules.update(try_decode(m, "ascii") for m in sys.builtin_module_names)
222259
path = sys.path
223-
260+
path = ['/Users/eerichart/bpython']
224261
for p in path:
225262
if not p:
226263
p = os.curdir

importtest.py

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
from bpython.importcompletion import find_modules
2+
import os
3+
4+
foo = find_modules(os.path.abspath("./importtestfolder"))
5+
6+
for thing in foo:
7+
print(thing)
8+
9+
#for obj in foo.nameSubname:
10+
#print(obj[0] + " " + obj[1])
11+
12+
#bpython import_completion yield name | #bpython import yield name subname and yield name
13+
#bpdb | #bpdb
14+
#__pycache__ | #__pycache__
15+
# | #bpython __pycache__
16+
#__pycache__ | #__pycache__
17+
# | #curtsiesfrontend __pycache__
18+
# | #bpython curtsiesfrontend.__pycache__
19+
#curtsiesfrontend | #curtsiesfrontend
20+
# | #bpython curtsiesfrontend
21+
#fodder | #fodder
22+
# | #test fodder
23+
# | #bpython test.fodder
24+
#test | #test
25+
# | #bpython test
26+
#__pycache__ | #__pycache__
27+
# | #translations __pycache__
28+
# | #bpython translations.__pycache__
29+
#LC_MESSAGES | #LC_MESSAGES
30+
# | #de LC_MESSAGES
31+
# | #translations de.LC_MESSAGES
32+
# | #bpython translations.de.LC_MESSAGES
33+
#de | #de
34+
#LC_MESSAGES | #LC_MESSAGES
35+
# | #es_ES LC_MESSAGES
36+
# | #translations es_ES.LC_MESSAGES
37+
# | #bpython translations.es_ES.LC_MESSAGES
38+
#es_ES | #es_ES
39+
#LC_MESSAGES | #LC_MESSAGES
40+
# | #fr_FR LC_MESSAGES
41+
# | #translations fr_FR.LC_MESSAGES
42+
# | #bpython translations.fr_FR.LC_MESSAGES
43+
#fr_FR | #fr_FR
44+
#LC_MESSAGES | #LC_MESSAGES
45+
# | #it_IT LC_MESSAGES
46+
# | #translations it_IT.LC_MESSAGES
47+
# | #bpython translations.it_IT.LC_MESSAGES
48+
#it_IT | #it_IT
49+
#LC_MESSAGES | #LC_MESSAGES
50+
# | #nl_NL LC_MESSAGES
51+
# | #translations nl_NL.LC_MESSAGES
52+
# | #bpython translations.nl_NL.LC_MESSAGES
53+
#nl_NL | #nl_NL
54+
#translations | #translations
55+
# | #bpython translations
56+
#bpython | #bpython
57+
#data | #data
58+
#source | #source
59+
# | #sphinx source
60+
# | #doc sphinx.source
61+
#sphinx | #sphinx
62+
# | #doc sphinx
63+
#doc | #doc
64+
#Level2 | #Level2
65+
# | #Level1 Level2
66+
# | #Level0 Level1.Level2
67+
# | #importtestfolder Level0.Level1.Level2
68+
#Level1 | #Level1
69+
#Level0 | #Level0
70+
# | #importtestfolder Level0
71+
#importtestfolder | #importtestfolder
72+
#pip-wheel-metadata | #pip-wheel-metadata
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/Users/eerichart/bpython/importtestfolder/Level0/Level1

importtestfolder/Level0/Level1/Level2/__init__.py

Whitespace-only changes.

importtestfolder/Level0/Level1/__init__.py

Whitespace-only changes.

importtestfolder/Level0/__init__.py

Whitespace-only changes.

importtestfolder/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)