mailr9706 - /1.3/version.py


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

Header


Content

Posted by edward on October 09, 2009 - 18:47:
Author: bugman
Date: Fri Oct  9 18:47:13 2009
New Revision: 9706

URL: http://svn.gna.org/viewcvs/relax?rev=9706&view=rev
Log:
Added a function to get the SVN URL.


Modified:
    1.3/version.py

Modified: 1.3/version.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/version.py?rev=9706&r1=9705&r2=9706&view=diff
==============================================================================
--- 1.3/version.py (original)
+++ 1.3/version.py Fri Oct  9 18:47:13 2009
@@ -58,3 +58,31 @@
         # The revision.
         if row[0] == 'Revision:':
             return row[1]
+
+
+def get_url():
+    """Attempt to retrieve the SVN URL, if this is a checked out copy.
+
+    @return:    The SVN URL, or None if unsuccessful.
+    @rtype:     None or str
+    """
+
+    # Does the base directory exist (i.e. is this a checked out copy).
+    if not access('.svn', F_OK):
+        return
+
+    # Try to run 'svn info'.
+    pipe = Popen('svn info', shell=True, stdin=PIPE, stdout=PIPE, 
stderr=PIPE, close_fds=True)
+
+    # Errors.
+    if pipe.stderr.readlines():
+        return
+
+    # Loop over the output lines.
+    for line in pipe.stdout.readlines():
+        # Split up the line.
+        row = split(line)
+
+        # The revision.
+        if row[0] == 'URL:':
+            return row[1]




Related Messages


Powered by MHonArc, Updated Fri Oct 09 19:00:02 2009