[Zope3-checkins] CVS: Zope3/utilities - finddeps.py:1.7

Fred L. Drake, Jr. fred at zope.com
Thu Mar 11 12:27:14 EST 2004


Update of /cvs-repository/Zope3/utilities
In directory cvs.zope.org:/tmp/cvs-serv21748

Modified Files:
	finddeps.py 
Log Message:
be more careful about handling the ZOPESRC prefix for paths


=== Zope3/utilities/finddeps.py 1.6 => 1.7 ===
--- Zope3/utilities/finddeps.py:1.6	Thu Mar 11 12:19:08 2004
+++ Zope3/utilities/finddeps.py	Thu Mar 11 12:27:14 2004
@@ -48,6 +48,7 @@
 # Get the Zope base path
 import zope
 ZOPESRC = os.path.dirname(os.path.dirname(zope.__file__))
+ZOPESRCPREFIX = os.path.join(ZOPESRC, "")
 
 # Matching expression for python files.
 pythonfile = re.compile(r'[a-zA-Z][a-zA-Z0-9_]*\.py')
@@ -57,6 +58,14 @@
 dottedName = re.compile(r'"[a-zA-Z\.][a-zA-Z0-9_\.]*"')
 
 
+def stripZopePrefix(path):
+    """Remove the '.../src/' prefix from path, if present."""
+    if path.startswith(ZOPESRCPREFIX):
+        return path[len(ZOPESRCPREFIX):]
+    else:
+        return path
+
+
 class Dependency(object):
     """Object representing a dependency."""
 
@@ -119,7 +128,7 @@
 
 def getDependenciesOfZCMLFile(path):
     """Get dependencies from ZCML file."""
-    localModule = os.path.dirname(path).replace(ZOPESRC+'/', '')
+    localModule = stripZopePrefix(os.path.dirname(path))
     localModule = localModule.replace('/', '.')
     deps = []
     lineno = 0
@@ -298,7 +307,7 @@
         if long:
             print '-'*len(dep.path)
             for file, lineno in dep.occurences:
-                file = file.replace(ZOPESRC+'/', '')
+                file = stripZopePrefix(file)
                 if len(file) >= 69:
                     file = '...' + file[:69-3]
                 print '  %s, Line %s' %(file, lineno)




More information about the Zope3-Checkins mailing list