I try to find all missing import statements and errors for each module and its modules.
Is there a special tool for what I'm trying to do?
The code I wrote, but it seems really awful and maybe something like this already exists:
import os
def find_missing_imports(walk):
for items in walk:
d = items[0]
f_list = items[1]
for f in f_list:
module = f[:-3]
module_path = d.lstrip('.').replace('/','.').lstrip('.')
try:
__import__(module_path, fromlist=[module])
except IndentationError, e:
pass
except NameError, e:
print(d,f,e)
pass
except Exception, e:
print(f,e)
pass
walk = [[root,files] for root,dirs,files in os.walk('.') for fn in files if fn.endswith('.py')]
find_missing_imports(walk)
Outputs:
.[snip]
('./Sky_Group_Inventory_Scanner-wxpython/display_image/Dialogs', 'ImageSelectionFrame.py', NameError("name 'wx' is not defined",))
('./Sky_Group_Inventory_Scanner-wxpython/display_image/Dialogs', 'ItemSpecificsDialog.py', NameError("name 'wx' is not defined",))
('./Sky_Group_Inventory_Scanner-wxpython/display_image/Dialogs', 'ReturnCorrectWatchTitle.py', NameError("name 'wx' is not defined",))
.[snip]
My project before refactoring was a mess, but kind of useful, now it's broken after refactoring.
After reading the "Pragmatic Programmer" based on the sentences of my initial codereview post:
I was looking for the source code:
/usr/local/lib/python2.7/dist-packages/rope
ROPE . Ninja-IDE, , .
, , , .
.

, .

, , , .
:
pylint -E /path/to/module