mailr20593 - /trunk/devel_scripts/python_seek.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by edward on August 14, 2013 - 18:54:
Author: bugman
Date: Wed Aug 14 18:54:19 2013
New Revision: 20593

URL: http://svn.gna.org/viewcvs/relax?rev=20593&view=rev
Log:
Improved the Python seeking and module version print out script for symlinks.

This should now be much more capable of finding all Python versions on a 
system.


Modified:
    trunk/devel_scripts/python_seek.py

Modified: trunk/devel_scripts/python_seek.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/devel_scripts/python_seek.py?rev=20593&r1=20592&r2=20593&view=diff
==============================================================================
--- trunk/devel_scripts/python_seek.py (original)
+++ trunk/devel_scripts/python_seek.py Wed Aug 14 18:54:19 2013
@@ -5,8 +5,8 @@
 
 
 # Python module imports.
-from os import X_OK, access, system
-from os.path import isfile, islink
+from os import X_OK, access, readlink, system
+from os.path import abspath, dirname, isabs, isfile, islink, join
 from subprocess import PIPE, Popen
 import sys
 
@@ -96,6 +96,17 @@
             # The file name.
             file = line[:-1]
 
+            # Recursively follow and expand links.
+            while 1:
+                if islink(file):
+                    orig = readlink(file)
+                    if not isabs(orig):
+                        orig = join(dirname(file), orig)
+                    file = orig
+                    continue
+                else:
+                    break
+
             # Check if the path is a file.
             if not isfile(file):
                 continue
@@ -104,12 +115,12 @@
             if not access(file, X_OK):
                 continue
 
-            # Check if the path is a link.
-            if islink(file):
-                continue
-
-            # Add the file.
-            binaries.append(file)
+            # Convert to an absolute path.
+            file = abspath(file)
+
+            # Add the file, avoiding duplicates.
+            if file not in binaries:
+                binaries.append(file)
 
         # Return the file list.
         return binaries




Related Messages


Powered by MHonArc, Updated Wed Aug 14 20:00:01 2013