[Zope3-checkins] SVN: Zope3/trunk/utilities/finddeps.py - add/clarify some docstrings

Fred L. Drake, Jr. fred at zope.com
Wed May 19 14:24:45 EDT 2004


Log message for revision 24829:
- add/clarify some docstrings
- minor code cleanups



-=-
Modified: Zope3/trunk/utilities/finddeps.py
===================================================================
--- Zope3/trunk/utilities/finddeps.py	2004-05-19 18:13:44 UTC (rev 24828)
+++ Zope3/trunk/utilities/finddeps.py	2004-05-19 18:24:44 UTC (rev 24829)
@@ -75,6 +75,17 @@
     """Object representing a dependency."""
 
     def __init__(self, path, file, lineno):
+        """Initialize a Dependency instance.
+
+        path -- dotted name of the module
+
+        file -- full path of a source file that depends on the module
+        named by path
+
+        lineno -- line number within file where the dependency was
+        identified (import or ZCML reference)
+
+        """
         self.path = path
         self.occurences = [(file, lineno)]
 
@@ -94,7 +105,7 @@
         return False
 
     def __cmp__(self, other):
-        """Compare dependecies by path."""
+        """Compare dependecies by module name."""
         return cmp(self.path, other.path)
 
 
@@ -106,15 +117,14 @@
     sys.exit(code)
 
 
-def makePythonPath(path):
+def makeDottedName(path):
     """Convert a path to a dotted module name, using sys.path."""
     syspaths = sys.path[1:]
     syspaths.append(os.getcwd())
     for syspath in syspaths:
+        syspath = os.path.join(syspath, '')
         if path.startswith(syspath):
-            cutPath = path.replace(syspath+os.sep, '')
-            dottedPath = dotjoin(cutPath.split(os.sep))
-            return dottedPath
+            return path[len(syspath):].replace(os.sep, ".")
 
     raise ValueError, 'Cannot create dotted name.'
 
@@ -347,10 +357,10 @@
     deps = filteredDeps
 
     # Filter absolute imports
-    dottedPath = makePythonPath(path)
+    dottedName = makeDottedName(path)
     filteredDeps = []
     for dep in deps:
-        if not dep.path.startswith(dottedPath):
+        if not dep.path.startswith(dottedName):
             filteredDeps.append(dep)
 
     return filteredDeps




More information about the Zope3-Checkins mailing list