[Checkins] SVN: z3c.configurator/trunk/importchecker.py nicer
output for emacs
Bernd Dorn
bernd.dorn at lovelysystems.com
Tue Jun 12 01:51:01 EDT 2007
Log message for revision 76631:
nicer output for emacs
Changed:
U z3c.configurator/trunk/importchecker.py
-=-
Modified: z3c.configurator/trunk/importchecker.py
===================================================================
--- z3c.configurator/trunk/importchecker.py 2007-06-11 22:32:38 UTC (rev 76630)
+++ z3c.configurator/trunk/importchecker.py 2007-06-12 05:50:59 UTC (rev 76631)
@@ -44,7 +44,7 @@
result.append(node.name)
return
elif name == 'AssAttr':
- return
+ return
for child in more_node.getChildNodes():
_findDottedNamesHelper(child, result)
@@ -115,7 +115,7 @@
self._map = findImports(mod)
dottednames = {}
self._dottednames = findDottedNames(mod)
-
+
def getPath(self):
"""Return the path to this module's file.
"""
@@ -140,7 +140,7 @@
if dottedname.startswith(usednamedot):
attrname = dottedname[len(usednamedot):].split('.')[0]
result.append((attrname, module_name))
-
+
return result
def getUnusedImports(self):
@@ -152,12 +152,12 @@
if usedname not in self._dottednames:
result.append((originalname, value['lineno']))
return result
-
+
class ModuleFinder:
def __init__(self):
self._files = []
-
+
def visit(self, arg, dirname, names):
"""This method will be called when we walk the filesystem
tree. It looks for python modules and stored their filenames.
@@ -189,7 +189,7 @@
self._root_path = root_path
self._modules = {}
self._names = {}
-
+
def resolveDottedModuleName(self, dotted_name, module):
"""Return path to file representing module, or None if no such
thing. Can do this relative from module.
@@ -245,7 +245,7 @@
if not modulepaths.has_key(self_path):
modulepaths[self_path] = 1
names[t] = modulepaths
-
+
def getUnusedImports(self):
"""Get unused imports of all known modules.
"""
@@ -266,7 +266,7 @@
if (tests and isTest) or (not tests and not isTest):
result.update(module.getImportedModuleNames())
return sorted(result)
-
+
def getUnusedImportsInModule(self, module):
"""Get all unused imports in a module.
"""
@@ -295,13 +295,13 @@
except IndexError:
path = os.path.abspath(os.getcwd())
path = os.path.join(path, 'src')
-
+
if not os.path.exists(path):
print "Please provide a valid path %r" % path
sys.exit(1)
- print "-"*80
+ print "-"*79
print "Path: %r" % path
- print "-"*80
+ print "-"*79
print
path = os.path.abspath(path)
@@ -309,18 +309,16 @@
print "Unknown path:", path
sys.exit(1)
- l = len(path) + 1
db = ImportDatabase(path)
db.findModules()
unused_imports = db.getUnusedImports()
module_paths = unused_imports.keys()
module_paths.sort()
- print "-"*80
+ print "-"*79
print "Unused Imports:"
- print "-"*80
+ print "-"*79
for path in module_paths:
info = unused_imports[path]
- path = path[l:]
if not info:
continue
line2names = {}
@@ -335,22 +333,22 @@
print "%s:%s: %s" % (path, line, names)
testImports = db.getImportedModuleNames(tests=True)
installImports = db.getImportedModuleNames(tests=False)
- print "-"*80
+ print "-"*79
print
- print "-"*80
+ print "-"*79
print "Imports for 'tests' and 'testing' packages"
- print "-"*80
+ print "-"*79
for name in [name for name in testImports if name not in installImports]:
print name
- print "-"*80
+ print "-"*79
print
- print "-"*80
+ print "-"*79
print "Install imports"
- print "-"*80
+ print "-"*79
for name in installImports:
print name
- print "-"*80
-
+ print "-"*79
+
if __name__ == '__main__':
main()
More information about the Checkins
mailing list