mailr9700 - /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:00:
Author: bugman
Date: Fri Oct  9 18:00:30 2009
New Revision: 9700

URL: http://svn.gna.org/viewcvs/relax?rev=9700&view=rev
Log:
Added a copyright notice and a function for returning the SVN revision number 
to the version module.


Modified:
    1.3/version.py

Modified: 1.3/version.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/version.py?rev=9700&r1=9699&r2=9700&view=diff
==============================================================================
--- 1.3/version.py (original)
+++ 1.3/version.py Fri Oct  9 18:00:30 2009
@@ -1,1 +1,60 @@
+###############################################################################
+#                                                                            
 #
+# Copyright (C) 2009 Edward d'Auvergne                                       
 #
+#                                                                            
 #
+# This file is part of the program relax.                                    
 #
+#                                                                            
 #
+# relax is free software; you can redistribute it and/or modify              
 #
+# it under the terms of the GNU General Public License as published by       
 #
+# the Free Software Foundation; either version 2 of the License, or          
 #
+# (at your option) any later version.                                        
 #
+#                                                                            
 #
+# relax is distributed in the hope that it will be useful,                   
 #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of             
 #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              
 #
+# GNU General Public License for more details.                               
 #
+#                                                                            
 #
+# You should have received a copy of the GNU General Public License          
 #
+# along with relax; if not, write to the Free Software                       
 #
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA  
 #
+#                                                                            
 #
+###############################################################################
+
+# Module docstring.
+"""Module for relax version information."""
+
+# Python module imports.
+from os import F_OK, access
+from string import split
+from subprocess import PIPE, Popen
+
+
 version = "repository checkout"
+
+
+def get_revision():
+    """Attempt to retrieve the SVN revision number, if this is a checked out 
copy.
+
+    @return:    The SVN revision number, 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] == 'Revision:':
+            return row[1]




Related Messages


Powered by MHonArc, Updated Fri Oct 09 18:20:02 2009