diff options
Diffstat (limited to 'qolab/file_utils/__init__.py')
-rw-r--r-- | qolab/file_utils/__init__.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/qolab/file_utils/__init__.py b/qolab/file_utils/__init__.py new file mode 100644 index 0000000..044f3c7 --- /dev/null +++ b/qolab/file_utils/__init__.py @@ -0,0 +1,30 @@ +import platform +import re +import os + +def filename2os_fname( fname ): + # filename2os_fname translate Win or Linux fname to OS dependent style + # takes in account the notion of 'Z:' drive on different systems + # Z:\dir1\dir2\file <==> /mnt/qol_grp_data/dir1/dir2/file + if platform.system() == 'Windows': + fname = re.sub('/mnt/qol_grp_data', 'Z:', fname) + else: + fname = re.sub('Z:', '/mnt/qol_grp_data', fname) + fname = re.sub(r'\\', '/', fname) + + fname = os.path.normpath(fname) + return (fname) + + +def get_runnum(savepath): + # For the provided datapath: + # reads, increments data counter and saves it back. + # If nesessary creates counter file and full path to it. + # example + # get_runnum('Z:\Ramsi_EIT\data\') + # get_runnum('/mnt/qol_grp_data/data') + pass + +def get_next_data_file(prefix, savepath): + run_number = get_runnum( savepath ) + |