diff options
author | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2024-06-25 23:36:31 -0400 |
---|---|---|
committer | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2024-06-25 23:36:31 -0400 |
commit | da84938d06877f860e03831f6f8a3d8e6140235e (patch) | |
tree | 013212a4145f499e5e3eba4be9e3c4297dc0201b /qolab/file_utils | |
parent | bafa1f84caee38f434fb77da9c6f2febf718920e (diff) | |
download | qolab-da84938d06877f860e03831f6f8a3d8e6140235e.tar.gz qolab-da84938d06877f860e03831f6f8a3d8e6140235e.zip |
converts comments to docstrings
Diffstat (limited to 'qolab/file_utils')
-rw-r--r-- | qolab/file_utils/__init__.py | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/qolab/file_utils/__init__.py b/qolab/file_utils/__init__.py index 9b7aeb2..d612c19 100644 --- a/qolab/file_utils/__init__.py +++ b/qolab/file_utils/__init__.py @@ -4,9 +4,13 @@ import os from datetime import date 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 + r"""Translate Windows or Linux filename to OS dependent style. + Takes in account the notion of 'Z:' drive on different systems. + + In particular replaces Z: <==> /mnt/qol_grp_data and \\ <==> / + + Example: 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: @@ -18,12 +22,12 @@ def filename2os_fname( fname ): def get_runnum(data_dir): - # For the provided data_dir: - # reads, increments data counter and saves it back. - # If necessary creates counter file and full path to it. - # example - # get_runnum('Z:\Ramsi_EIT\data\') - # get_runnum('/mnt/qol_grp_data/data') + r""" Reads, increments data counter and saves it back in the provided `data_dir`. + If necessary creates counter file and full path to it. + Examples": + get_runnum('Z:\\Ramsi_EIT\\data\\') + get_runnum('/mnt/qol_grp_data/data') + """ data_dir = filename2os_fname( data_dir ); if not os.path.exists(data_dir): os.mkdir(data_dir) @@ -61,6 +65,10 @@ def get_runnum(data_dir): return(run_number) def get_next_data_file(prefix, savepath, run_number=None, datestr=None, date_format='%Y%m%d', extension='dat'): + """Generate a filename according to a standard naming scheme + fname = os.path.join(savepath, f'{prefix}_{datestr}_{run_number:05d}.{extension}') + if run_number is missing, acquires it with `get_runnum( savepath )` + """ if run_number is None: run_number = get_runnum( savepath ) today = date.today() |