[Checkins] SVN: Sandbox/janwijbrand/importchecker/trunk/ Report absolute paths when needed, relative paths when possible.

Jan-Wijbrand Kolman janwijbrand at gmail.com
Tue Jun 3 06:04:48 EDT 2008


Log message for revision 87125:
  Report absolute paths when needed, relative paths when possible.

Changed:
  U   Sandbox/janwijbrand/importchecker/trunk/CHANGES.txt
  U   Sandbox/janwijbrand/importchecker/trunk/src/importchecker/importchecker.py

-=-
Modified: Sandbox/janwijbrand/importchecker/trunk/CHANGES.txt
===================================================================
--- Sandbox/janwijbrand/importchecker/trunk/CHANGES.txt	2008-06-03 09:04:42 UTC (rev 87124)
+++ Sandbox/janwijbrand/importchecker/trunk/CHANGES.txt	2008-06-03 10:04:47 UTC (rev 87125)
@@ -4,7 +4,8 @@
 1.1 (unreleased)
 ----------------
 
-...
+* Report the absolute path for modules when needed, relative paths (relative
+  to the current working directory, that is) when possible.
 
 1.0 (2008-05-06)
 ----------------

Modified: Sandbox/janwijbrand/importchecker/trunk/src/importchecker/importchecker.py
===================================================================
--- Sandbox/janwijbrand/importchecker/trunk/src/importchecker/importchecker.py	2008-06-03 09:04:42 UTC (rev 87124)
+++ Sandbox/janwijbrand/importchecker/trunk/src/importchecker/importchecker.py	2008-06-03 10:04:47 UTC (rev 87125)
@@ -291,6 +291,9 @@
 
 
 def main(path=None):
+    cwd = os.getcwd()
+    lencwd = len(cwd)+1
+
     try:
         path = path or sys.argv[1]
     except IndexError:
@@ -302,7 +305,6 @@
         print "Unknown path:", path
         sys.exit(1)
 
-    l = len(path) + 1
     db = ImportDatabase(path)
     db.findModules()
     unused_imports = db.getUnusedImports()
@@ -310,7 +312,8 @@
     module_paths.sort()
     for path in module_paths:
         info = unused_imports[path]
-        path = path[l:]
+        if path.startswith(cwd):
+            path = path[lencwd:]
         if not info:
             continue
         line2names = {}



More information about the Checkins mailing list