[Zope3-checkins] CVS: Zope3/utilities - finddeps.py:1.14
Fred L. Drake, Jr.
fred at zope.com
Fri Mar 12 12:36:00 EST 2004
Update of /cvs-repository/Zope3/utilities
In directory cvs.zope.org:/tmp/cvs-serv19471
Modified Files:
finddeps.py
Log Message:
- clarify a docstring and exception message
- try to be more platform agnostic
- fix inspection of single files (previously called a function that
didn't exist; now it calls the right function for the type of file
being checked)
=== Zope3/utilities/finddeps.py 1.13 => 1.14 ===
--- Zope3/utilities/finddeps.py:1.13 Fri Mar 12 11:08:49 2004
+++ Zope3/utilities/finddeps.py Fri Mar 12 12:35:58 2004
@@ -104,16 +104,16 @@
def makePythonPath(path):
- """Make out of a patha dotted Python path, using sys.path"""
+ """Convert a path to a dotted module name, using sys.path."""
syspaths = sys.path[1:]
syspaths.append(os.getcwd())
for syspath in syspaths:
if path.startswith(syspath):
- cutPath = path.replace(syspath+'/', '')
- dottedPath = '.'.join(cutPath.split('/'))
+ cutPath = path.replace(syspath+os.sep, '')
+ dottedPath = dotjoin(cutPath.split(os.sep))
return dottedPath
- raise ValueError, 'Cannot create dotted path.'
+ raise ValueError, 'Cannot create dotted name.'
START = "<start>"
@@ -276,7 +276,7 @@
def getDependenciesOfZCMLFile(path):
"""Get dependencies from ZCML file."""
localModule = stripZopePrefix(os.path.dirname(path))
- localModule = localModule.replace('/', '.')
+ localModule = localModule.replace(os.sep, '.')
deps = []
lineno = 0
for line in open(path, 'r'):
@@ -398,7 +398,15 @@
deps += getDependencies(filePath)
elif os.path.isfile(path):
- deps = getDependenciesOfFile(path)
+ ext = os.path.splitext(path)[1]
+ if ext == ".py":
+ deps = getDependenciesOfPythonFile(path)
+ elif ext == ".zcml":
+ deps = getDependenciesOfZCMLFile(path)
+ else:
+ print >>sys.stderr, ("dependencies can only be"
+ " extracted from Python and ZCML files")
+ sys.exit(1)
return deps
More information about the Zope3-Checkins
mailing list