@@ -66,6 +66,7 @@ def __init__(
66
66
skiplist if skiplist is not None else tuple ()
67
67
)
68
68
self .fully_loaded = False
69
+ self .print_packages_traversed = False
69
70
70
71
if paths is None :
71
72
self .modules .update (sys .builtin_module_names )
@@ -220,6 +221,8 @@ def find_modules(
220
221
continue
221
222
if (stat .st_dev , stat .st_ino ) not in self .paths :
222
223
self .paths .add ((stat .st_dev , stat .st_ino ))
224
+ if (self .print_packages_traversed ):
225
+ print (path_real )
223
226
for subname in self .find_modules (path_real ):
224
227
if subname is None :
225
228
yield None # take a break to avoid unresponsiveness
@@ -250,3 +253,33 @@ def find_coroutine(self) -> Optional[bool]:
250
253
self .fully_loaded = True
251
254
252
255
return True
256
+
257
+
258
+ def discover (
259
+ skiplist : Optional [Sequence [str ]] = None ,
260
+ print_packages_traversed = True
261
+ ):
262
+ module_gatherer = ModuleGatherer (skiplist = skiplist )
263
+ module_gatherer .print_packages_traversed = print_packages_traversed
264
+ while module_gatherer .find_coroutine ():
265
+ pass
266
+
267
+
268
+ if __name__ == "__main__" :
269
+ import argparse
270
+ from pathlib import Path
271
+
272
+ from bpython .config import Config , default_config_path
273
+
274
+ parser = argparse .ArgumentParser ()
275
+ parser .add_argument (
276
+ "--config" ,
277
+ default = default_config_path (),
278
+ type = Path ,
279
+ help = "Use CONFIG instead of default config file." ,
280
+ )
281
+ config = Config (default_config_path ())
282
+ discover (
283
+ config .import_completion_skiplist ,
284
+ print_packages_traversed = True
285
+ )
0 commit comments