mailr27124 - /trunk/lib/io.py


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

Header


Content

Posted by edward on December 18, 2014 - 10:35:
Author: bugman
Date: Thu Dec 18 10:35:22 2014
New Revision: 27124

URL: http://svn.gna.org/viewcvs/relax?rev=27124&view=rev
Log:
Implemented the lib.io.swap_extension() function.

This is confirmed to be fully functional by its four unit tests.


Modified:
    trunk/lib/io.py

Modified: trunk/lib/io.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/lib/io.py?rev=27124&r1=27123&r2=27124&view=diff
==============================================================================
--- trunk/lib/io.py     (original)
+++ trunk/lib/io.py     Thu Dec 18 10:35:22 2014
@@ -539,6 +539,28 @@
     return new
 
 
+def swap_extension(file=None, ext=None):
+    """Swap one file name extension for another.
+
+    @keyword file:  The name of the original file.
+    @type file:     str
+    @keyword ext:   The new file name extension to use.
+    @type ext:      str
+    @return:        The name of the file with the new file name extension.
+    @rtype:         str
+    """
+
+    # The file root.
+    new_file = file_root(file)
+
+    # Add the new extension.
+    new_file += '.'
+    new_file += ext
+
+    # Return the new file name.
+    return new_file
+
+
 def test_binary(binary):
     """Function for testing that the binary string corresponds to a valid 
executable file.
 




Related Messages


Powered by MHonArc, Updated Thu Dec 18 11:20:02 2014