mailr6489 - /1.3/relax_io.py


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

Header


Content

Posted by edward on June 25, 2008 - 00:40:
Author: bugman
Date: Wed Jun 25 00:04:53 2008
New Revision: 6489

URL: http://svn.gna.org/viewcvs/relax?rev=6489&view=rev
Log:
Modified the extract_data() function to allow file objects to be passed into 
it.


Modified:
    1.3/relax_io.py

Modified: 1.3/relax_io.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/relax_io.py?rev=6489&r1=6488&r2=6489&view=diff
==============================================================================
--- 1.3/relax_io.py (original)
+++ 1.3/relax_io.py Wed Jun 25 00:04:53 2008
@@ -86,14 +86,14 @@
     return compress_type, file_path
 
 
-def extract_data(file_name=None, dir=None, file_data=None, sep=None):
-    """Open the file 'file' and return all the data.
-
-    @param file_name:       The name of the file to extract the data from.
-    @type file_name:        str
-    @param dir:             The path where the file is located.  If None, 
then the current
-                            directory is assumed.
-    @type dir:              str
+def extract_data(file=None, dir=None, file_data=None, sep=None):
+    """Return all data in the file as a list of lines where each line is a 
list of line elements.
+
+    @param file:            The file to extract the data from.
+    @type file:             str or file object
+    @param dir:             The path where the file is located.  If None and 
the file argument is a
+                            string, then the current directory is assumed.
+    @type dir:              str or None
     @param file_data:       If the file data has already been extracted from 
the file, it can be
                             passed into this function using this argument.  
If data is supplied
                             here, then the file_name and dir args are 
ignored.
@@ -108,7 +108,8 @@
     # Data not already extracted from the file.
     if not file_data:
         # Open the file.
-        file = open_read_file(file_name=file_name, dir=dir)
+        if type(file) != file:
+            file = open_read_file(file_name=file_name, dir=dir)
 
         # Read lines.
         file_data = file.readlines()




Related Messages


Powered by MHonArc, Updated Wed Jun 25 02:20:13 2008