From 1945b8490598f2097402287e4d81cff903019c45 Mon Sep 17 00:00:00 2001 From: Kshemaahna <63880115+Kshemaahna@users.noreply.github.com> Date: Wed, 30 Apr 2025 13:41:07 -0700 Subject: [PATCH 1/3] Update cli.py --- caltechdata_api/cli.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/caltechdata_api/cli.py b/caltechdata_api/cli.py index c23bf8a..04ab3ad 100644 --- a/caltechdata_api/cli.py +++ b/caltechdata_api/cli.py @@ -405,8 +405,13 @@ def upload_supporting_file(record_id=None): print("\n".join(files)) while True: filename = get_user_input( - "Enter the filename to upload as a supporting file (or 'n' to finish): " + "Enter the filename to upload as a supporting file (or '*' to get all files currently in the directory, otherwise 'n' to finish): " ) + if filename == "*": + for files_name in files: + filepath = os.path.abspath(files_name) + filepaths.append(filepath) + print("All files added successfully") if filename == "n": break if filename in files: @@ -420,6 +425,7 @@ def upload_supporting_file(record_id=None): else: filepath = os.path.abspath(filename) filepaths.append(filepath) + print("File added successfully") else: print( f"Error: File '{filename}' not found. Please enter a valid filename." From b01a1984f21f8efa2be169f23599a9aacae9df73 Mon Sep 17 00:00:00 2001 From: Kshemaahna <63880115+Kshemaahna@users.noreply.github.com> Date: Wed, 30 Apr 2025 13:53:46 -0700 Subject: [PATCH 2/3] Update cli.py --- caltechdata_api/cli.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/caltechdata_api/cli.py b/caltechdata_api/cli.py index 04ab3ad..5e0a467 100644 --- a/caltechdata_api/cli.py +++ b/caltechdata_api/cli.py @@ -412,9 +412,9 @@ def upload_supporting_file(record_id=None): filepath = os.path.abspath(files_name) filepaths.append(filepath) print("All files added successfully") - if filename == "n": + elif filename == "n": break - if filename in files: + elif filename in files: file_size = os.path.getsize(filename) if file_size > 1024 * 1024 * 1024: print( From 425c483e1fc24f3a17dcca11b0b50cc5b29ffa2c Mon Sep 17 00:00:00 2001 From: Kshemaahna <63880115+Kshemaahna@users.noreply.github.com> Date: Wed, 28 May 2025 12:58:51 -0700 Subject: [PATCH 3/3] Update cli.py Implementation a feature such that users can choose a file from inside the current directory based on a displayed index instead of a filename, collision of filenames with indices handled with the help of a special character --- caltechdata_api/cli.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/caltechdata_api/cli.py b/caltechdata_api/cli.py index 5e0a467..bb29f97 100644 --- a/caltechdata_api/cli.py +++ b/caltechdata_api/cli.py @@ -360,6 +360,7 @@ def upload_supporting_file(record_id=None): filepaths = [] file_link = "" file_links = [] + idx = 0 while True: choice = get_user_input( "Do you want to upload or link data files? (upload/link/n): " @@ -402,10 +403,10 @@ def upload_supporting_file(record_id=None): files = [ f for f in os.listdir() if not f.endswith(".json") and os.path.isfile(f) ] - print("\n".join(files)) + print((""+ str(++idx) + "/ \n").join(files)) while True: filename = get_user_input( - "Enter the filename to upload as a supporting file (or '*' to get all files currently in the directory, otherwise 'n' to finish): " + "Enter the filename to upload as a supporting file (or '*' to get all files currently in the directory, or the index number of the file as displayed followed by a /, otherwise 'n' to finish): " ) if filename == "*": for files_name in files: @@ -414,6 +415,11 @@ def upload_supporting_file(record_id=None): print("All files added successfully") elif filename == "n": break + elif filename[len(filename)-1] == '/': + files_name = files[int(filename[0])-1] + filepath = os.path.abspath(files_name) + filepaths.append(filepath) + print("File added successfully") elif filename in files: file_size = os.path.getsize(filename) if file_size > 1024 * 1024 * 1024: