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

Philipp von Weitershausen philikon at philikon.de
Thu Mar 25 08:47:54 EST 2004


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

Modified Files:
	finddeps.py 
Log Message:
Renamed the -m option to -d because what you were really specifying was
a directory path. Added an -m option for a dotted module name. Now you 
can do:

  utilities/finddeps -m zope.pagetemplate

is equal to

  utilities/finddeps -d src/zope/pagetemplate


=== Zope3/utilities/finddeps.py 1.14 => 1.15 ===
--- Zope3/utilities/finddeps.py:1.14	Fri Mar 12 12:35:58 2004
+++ Zope3/utilities/finddeps.py	Thu Mar 25 08:47:53 2004
@@ -30,8 +30,11 @@
         If long is specified, the file and line where the dependency occurs is
         reported.
 
+    -d / --dir
+        Specify the path of the module that is to be inspected.
+
     -m / --module
-        Specify the path of the module that is being inspected.
+        Specify the dotted name of the module that is to be inspected.
 
     -z / --zcml
         Also look through ZCML files for dependencies.
@@ -473,14 +476,14 @@
     try:
         opts, args = getopt.getopt(
             sys.argv[1:],
-            'm:ahlz',
-            ['all', 'help', 'module=', 'long', 'zcml'])
+            'd:m:ahlz',
+            ['all', 'help', 'dir=', 'module=', 'long', 'zcml'])
     except getopt.error, msg:
         usage(1, msg)
 
     all = False
     long = False
-    module = None
+    path = None
     zcml = False
     for opt, arg in opts:
         if opt in ('-a', '--all'):
@@ -489,15 +492,21 @@
             usage(0)
         elif opt in ('-l', '--long'):
             long = True
-        elif opt in ('-m', '--module'):
+        elif opt in ('-d', '--dir'):
             cwd = os.getcwd()
             # This is for symlinks. Thanks to Fred for this trick.
             if os.environ.has_key('PWD'):
                 cwd = os.environ['PWD']
-            module = os.path.normpath(os.path.join(cwd, arg))
+            path = os.path.normpath(os.path.join(cwd, arg))
+        elif opt in ('-m', '--module'):
+            try:
+                module = __import__(arg, globals(), locals(), ('something',))
+                path = os.path.dirname(module.__file__)
+            except ImportError:
+                usage(1, "Could not import module %s" % module)
         elif opt in ('-z', '--zcml'):
             zcml = True
-
-    if module is None:
-        usage(1, 'The module must be specified.')
-    showDependencies(module, zcml, long, all)
+    if path is None:
+        usage(1, 'The module must be specified either by path, '
+              'dotted name or ZCML file.')
+    showDependencies(path, zcml, long, all)




More information about the Zope3-Checkins mailing list