mailr26932 - /branches/nmrglue/pipe_control/io.py


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

Header


Content

Posted by tlinnet on December 03, 2014 - 18:38:
Author: tlinnet
Date: Wed Dec  3 18:38:23 2014
New Revision: 26932

URL: http://svn.gna.org/viewcvs/relax?rev=26932&view=rev
Log:
Added function file_list() in pipe_control.io to store file lists in cdp.

Task #7873 (https://gna.org/task/index.php?7873): Write wrapper function to 
nmrglue, to read .ft2 files and process them.
Homepage: http://www.nmrglue.com/
Link to nmrglue discussion: 
https://groups.google.com/forum/#!forum/nmrglue-discuss
The code is develop at Github: https://github.com/jjhelmus/nmrglue/
Documentation: http://nmrglue.readthedocs.org/en/latest/index.html

Modified:
    branches/nmrglue/pipe_control/io.py

Modified: branches/nmrglue/pipe_control/io.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/nmrglue/pipe_control/io.py?rev=26932&r1=26931&r2=26932&view=diff
==============================================================================
--- branches/nmrglue/pipe_control/io.py (original)
+++ branches/nmrglue/pipe_control/io.py Wed Dec  3 18:38:23 2014
@@ -24,6 +24,7 @@
 
 # relax module imports.
 from lib.errors import RelaxError
+from lib.io import get_file_list
 from pipe_control.pipes import check_pipe
 
 
@@ -45,3 +46,28 @@
     # Add the data under the dictionary key.
     obj_dict = getattr(cdp, object_name)
     obj_dict[io_id] = io_data
+
+
+def file_list(glob=None, dir=None, id=None):
+    """Store in cdp.io_basename and cdp.io_file_root, a list of file 
basenames and a list of fileroot matching the pathname pattern.  It is stored 
in a dictionary with key 'id'.
+    If 'id' is set to None, it is stored with the key set to the glob 
pattern.
+
+    @param glob:            Glob pattern that may contain simple shell-style 
wildcards.
+    @type glob:             str
+    @param dir:             The path where the files is located.  If None, 
then the current directory is assumed.
+    @type dir:              str
+    @param id:              The id to use as dictionary key, to store the 
file list.  If None, then the glob pattern is used as id.
+    @type id:               None or str
+    """
+
+    # Get the file list.
+    basename_list, file_root_list = get_file_list(glob_pattern=glob, dir=dir)
+
+    # Store the results.
+    if id == None:
+        id = glob
+
+    # Store in cdp.
+    add_io_data(object_name='io_basename', io_id=id, io_data=basename_list)
+    add_io_data(object_name='io_file_root', io_id=id, io_data=file_root_list)
+    add_io_data(object_name='io_dir', io_id=id, io_data=dir)




Related Messages


Powered by MHonArc, Updated Wed Dec 03 18:40:02 2014