Author: bugman
Date: Mon Apr 17 11:36:22 2006
New Revision: 2481
URL: http://svn.gna.org/viewcvs/relax?rev=2481&view=rev
Log:
The null device can now be opened instead of a file for writing by passing 
'devnull' as the name.
Modified:
    1.2/io.py
Modified: 1.2/io.py
URL: 
http://svn.gna.org/viewcvs/relax/1.2/io.py?rev=2481&r1=2480&r2=2481&view=diff
==============================================================================
--- 1.2/io.py (original)
+++ 1.2/io.py Mon Apr 17 11:36:22 2006
@@ -33,7 +33,7 @@
 # Gzip compression module.
 from gzip import GzipFile
 
-from os import F_OK, access, makedirs, remove, stat
+from os import F_OK, access, devnull, makedirs, remove, stat
 from os.path import expanduser
 from re import match, search
 from string import split
@@ -245,6 +245,21 @@
     def open_write_file(self, file_name=None, dir=None, force=0, 
compress_type=0, print_flag=1, return_path=0):
         """Function for opening a file for writing and creating directories 
if necessary."""
 
+        # The null device.
+        if search('devnull', file_name):
+            # Print out.
+            if print_flag:
+                print "Opening the null device file for writing."
+
+            # Open the null device.
+            file = open(devnull, 'w')
+
+            # Return the file.
+            if return_path:
+                return file, None
+            else:
+                return file
+
         # Create the directories.
         self.mkdir(dir, print_flag=0)