[Python-modules-commits] r6993 - in tools (find_python_dependencies.py)

morph at users.alioth.debian.org morph at users.alioth.debian.org
Thu Nov 27 23:08:33 UTC 2008


    Date: Thursday, November 27, 2008 @ 23:08:33
  Author: morph
Revision: 6993

some pylint fixes

Modified:
  tools/find_python_dependencies.py

Modified: tools/find_python_dependencies.py
===================================================================
--- tools/find_python_dependencies.py	2008-11-27 21:10:11 UTC (rev 6992)
+++ tools/find_python_dependencies.py	2008-11-27 23:08:33 UTC (rev 6993)
@@ -49,7 +49,7 @@
     """Errors accessing module information"""
     pass
 
-def convertImportToDebianPkg(imp):
+def convert_import_to_debian_pkg(imp):
     """Tries to identify the Debian package from the module name"""
     try:
         # import the module, mapping it to 'mod'
@@ -81,22 +81,21 @@
         return pkg
     except ImportError, e:
         # module not found
-        print "E: ImportError while checking %s; exception: %s" % (imp,str(e))
+        print "E: ImportError while checking %s; exception: %s" % (imp, str(e))
         raise ImportNotFound()
     except Exception, e:
         # __file__ attribute doesn't exist or any other error
-        print "E: error while checking %s; exception: %s" % (imp,str(e))
+        print "E: error while checking %s; exception: %s" % (imp, str(e))
         raise ImportParseError()
 
-# find all py files in a given directory
-# thanks to recipe 2.19 from Python Cookbook
 def find_py_files_in_dir(path):
+    """Find all py files in a given directory; thanks to recipe 2.19 from Python Cookbook"""
     # pattern matching any case of "py" extension
     for match in glob.glob(os.path.join(path, "*.[Pp][Yy]")):
         yield match
 
-# find all py files in a given directory, then go recursing subdirs
 def find_py_files_in_dir_recursive(path):
+    """Find all py files in a given directory, then go recursing subdirs"""
     # check first in the dir passed as parameter
     for match in find_py_files_in_dir(path):
         yield match
@@ -110,7 +109,7 @@
             for subfile in find_py_files_in_dir_recursive(subpath):
                 yield subfile
 
-def parseFileImport(file):
+def parse_file_import(file):
     """Parses file's syntax tree to extract import statements"""
     try:
         # creates the syntax tree
@@ -119,16 +118,16 @@
         nodes = mod.node.nodes
 
         for node in nodes:
-            if isinstance(node,Import):
+            if isinstance(node, Import):
                 for name, alias in node.names:
                     yield name
-            if isinstance(node,From):
+            if isinstance(node, From):
                 yield node.modname
     except Exception, e:
         print "Error parsing " + file + "; exception: " + str(e)
 
 
-def addValuesToDict(dict, key, value):
+def add_value_to_dict(dict, key, value):
     """Adds value to dict[key], or add the item if missing"""
     if key in dict:
         dict[key] += value
@@ -144,13 +143,13 @@
 
 # main file parse loop
 for file in find_py_files_in_dir_recursive(sys.argv[1]):
-    for imp in parseFileImport(file):
-        addValuesToDict(import_dict, imp, 1)
+    for imp in parse_file_import(file):
+        add_value_to_dict(import_dict, imp, 1)
 
 # loop to identify the deb pkg containg each module, or add to discards list
 for module, count in import_dict.iteritems():
     try:
-        pkg = convertImportToDebianPkg(module)
+        pkg = convert_import_to_debian_pkg(module)
         mod_pkgs[module] = (pkg, count)
     except ImportNotFound:
         mod_not_found[module] = ('module not found on this machine', count)




More information about the Python-modules-commits mailing list