From 56d72f7de85b7ecae9cae27283ab68e24df0b1fc Mon Sep 17 00:00:00 2001 From: "Eugeniy E. Mikhailov" Date: Fri, 3 Dec 2021 19:37:05 -0500 Subject: draft of fileutilites --- qolab/file_utils/__init__.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 qolab/file_utils/__init__.py (limited to 'qolab/file_utils') 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 ) + -- cgit v1.2.3