[Checkins] SVN: zope.dependencytool/trunk/src/zope/dependencytool/finddeps.py try to guess output width

Fred L. Drake, Jr. fdrake at gmail.com
Wed Apr 23 19:52:58 EDT 2008


Log message for revision 85671:
  try to guess output width
  

Changed:
  U   zope.dependencytool/trunk/src/zope/dependencytool/finddeps.py

-=-
Modified: zope.dependencytool/trunk/src/zope/dependencytool/finddeps.py
===================================================================
--- zope.dependencytool/trunk/src/zope/dependencytool/finddeps.py	2008-04-23 23:14:31 UTC (rev 85670)
+++ zope.dependencytool/trunk/src/zope/dependencytool/finddeps.py	2008-04-23 23:52:57 UTC (rev 85671)
@@ -285,6 +285,14 @@
     else:
         deps = getCleanedDependencies(path, zcml, packages)
 
+    width = 80
+    if "COLUMNS" in os.environ:
+        try:
+            width = int(os.environ["COLUMNS"])
+        except ValueError:
+            pass
+    avail = width - 11
+
     if long:
         print '='*(8+len(path))
         print "Module: " + path
@@ -295,8 +303,8 @@
             print '-'*len(dep.name)
             for file, lineno in dep.occurences:
                 file = stripZopePrefix(file)
-                if len(file) >= 69:
-                    file = '...' + file[:69-3]
+                if len(file) >= avail:
+                    file = '...' + file[:avail-3]
                 print '  %s, Line %s' %(file, lineno)
             print
 



More information about the Checkins mailing list