diff options
author | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2021-12-03 19:37:05 -0500 |
---|---|---|
committer | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2021-12-03 19:37:05 -0500 |
commit | 56d72f7de85b7ecae9cae27283ab68e24df0b1fc (patch) | |
tree | 52a14fa707b3cd8e88fa5a4d264d21c086ac2166 | |
parent | d44e964463134d8fcc0d196a802269a9f02d76b6 (diff) | |
download | pyExpControl-56d72f7de85b7ecae9cae27283ab68e24df0b1fc.tar.gz pyExpControl-56d72f7de85b7ecae9cae27283ab68e24df0b1fc.zip |
draft of fileutilites
-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 ) + |