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 01/11] 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 02/11] 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 03/11] 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: From 67eecdb7963c4112023f66fc61f3d877872a6d01 Mon Sep 17 00:00:00 2001 From: Kshemaahna <63880115+Kshemaahna@users.noreply.github.com> Date: Fri, 20 Jun 2025 19:41:48 -0700 Subject: [PATCH 04/11] Update codemeta.json --- codemeta.json | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/codemeta.json b/codemeta.json index bd331b7..7634f3b 100755 --- a/codemeta.json +++ b/codemeta.json @@ -49,7 +49,17 @@ }, "email": "aabakah@caltech.edu", "@id": "https://orcid.org/0009-0003-5640-6691" - } + }, + { + "@type": "Person", + "givenName": "Kshemaahna", + "familyName": "Nagi", + "affiliation": { + "@type": "Organization", + "name": "Caltech" + }, + "@id": "https://orcid.org/0009-0002-8113-3763" + }, ], "developmentStatus": "active", "downloadUrl": "https://github.com/caltechlibrary/caltechdata_api/archive/1.9.1.zip", @@ -84,4 +94,4 @@ }, "programmingLanguage": "Python", "identifier": "10.22002/3gdk4-j5504" -} \ No newline at end of file +} From 0fd8ddf7c6dd4f7f96df35a5122b3098cfae9c84 Mon Sep 17 00:00:00 2001 From: Kshemaahna <63880115+Kshemaahna@users.noreply.github.com> Date: Fri, 20 Jun 2025 19:42:43 -0700 Subject: [PATCH 05/11] Update codemeta.json --- codemeta.json | 1 + 1 file changed, 1 insertion(+) diff --git a/codemeta.json b/codemeta.json index 7634f3b..5239e5c 100755 --- a/codemeta.json +++ b/codemeta.json @@ -58,6 +58,7 @@ "@type": "Organization", "name": "Caltech" }, + "email": "knagi@caltech.edu", "@id": "https://orcid.org/0009-0002-8113-3763" }, ], From 47ecb36d987a09eff6aefb97e15ba9b33e8c9d0b Mon Sep 17 00:00:00 2001 From: Kshemaahna <63880115+Kshemaahna@users.noreply.github.com> Date: Fri, 20 Jun 2025 19:48:17 -0700 Subject: [PATCH 06/11] Update cli.py --- caltechdata_api/cli.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/caltechdata_api/cli.py b/caltechdata_api/cli.py index bb29f97..535231f 100644 --- a/caltechdata_api/cli.py +++ b/caltechdata_api/cli.py @@ -403,7 +403,8 @@ 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((""+ str(++idx) + "/ \n").join(files)) + idx+=1 + 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, or the index number of the file as displayed followed by a /, otherwise 'n' to finish): " From 3724c8656238620b667c14c6994a7cc66026dfaa Mon Sep 17 00:00:00 2001 From: Kshemaahna <63880115+Kshemaahna@users.noreply.github.com> Date: Fri, 20 Jun 2025 19:54:48 -0700 Subject: [PATCH 07/11] Update cli.py --- caltechdata_api/cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/caltechdata_api/cli.py b/caltechdata_api/cli.py index 535231f..9689fd1 100644 --- a/caltechdata_api/cli.py +++ b/caltechdata_api/cli.py @@ -404,7 +404,7 @@ def upload_supporting_file(record_id=None): f for f in os.listdir() if not f.endswith(".json") and os.path.isfile(f) ] idx+=1 - print((""+ str(idx) + "/ \n").join(files)) + print((f"{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, or the index number of the file as displayed followed by a /, otherwise 'n' to finish): " From 3c1af9ffb1bb0f92203917deed3f63ca8b423c67 Mon Sep 17 00:00:00 2001 From: Kshemaahna <63880115+Kshemaahna@users.noreply.github.com> Date: Fri, 20 Jun 2025 20:10:22 -0700 Subject: [PATCH 08/11] Update cli.py --- caltechdata_api/cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/caltechdata_api/cli.py b/caltechdata_api/cli.py index 9689fd1..7744de1 100644 --- a/caltechdata_api/cli.py +++ b/caltechdata_api/cli.py @@ -416,7 +416,7 @@ def upload_supporting_file(record_id=None): print("All files added successfully") elif filename == "n": break - elif filename[len(filename)-1] == '/': + elif len(filename) != 0 and filename[len(filename)-1] == '/': files_name = files[int(filename[0])-1] filepath = os.path.abspath(files_name) filepaths.append(filepath) From fe526bdcc634579fa2c0722052e1ba7c5fac5c87 Mon Sep 17 00:00:00 2001 From: Kshemaahna <63880115+Kshemaahna@users.noreply.github.com> Date: Fri, 20 Jun 2025 20:13:19 -0700 Subject: [PATCH 09/11] Update cli.py --- caltechdata_api/cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/caltechdata_api/cli.py b/caltechdata_api/cli.py index 7744de1..63debd6 100644 --- a/caltechdata_api/cli.py +++ b/caltechdata_api/cli.py @@ -416,7 +416,7 @@ def upload_supporting_file(record_id=None): print("All files added successfully") elif filename == "n": break - elif len(filename) != 0 and filename[len(filename)-1] == '/': + elif filename == "": files_name = files[int(filename[0])-1] filepath = os.path.abspath(files_name) filepaths.append(filepath) From 92a7c6e5369e52bb301f4c2b30e911085fd9ea4a Mon Sep 17 00:00:00 2001 From: Kshemaahna <63880115+Kshemaahna@users.noreply.github.com> Date: Fri, 20 Jun 2025 20:16:46 -0700 Subject: [PATCH 10/11] 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 63debd6..e513c13 100644 --- a/caltechdata_api/cli.py +++ b/caltechdata_api/cli.py @@ -407,7 +407,7 @@ def upload_supporting_file(record_id=None): print((f"{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, or the index number of the file as displayed followed by a /, otherwise 'n' to finish): " + "Enter the filename to upload as a supporting file (or '*' to get all files currently in this directory, or the index number of the file as displayed followed by a /, otherwise 'n' to finish): " ) if filename == "*": for files_name in files: @@ -416,7 +416,7 @@ def upload_supporting_file(record_id=None): print("All files added successfully") elif filename == "n": break - elif filename == "": + elif (not len(filename) == 0) and (filename[len(filename) - 1] == '/'): files_name = files[int(filename[0])-1] filepath = os.path.abspath(files_name) filepaths.append(filepath) From 761053455f2151d614ed48e681f89791e5601e42 Mon Sep 17 00:00:00 2001 From: Kshemaahna <63880115+Kshemaahna@users.noreply.github.com> Date: Fri, 20 Jun 2025 20:25:09 -0700 Subject: [PATCH 11/11] Update cli.py --- caltechdata_api/cli.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/caltechdata_api/cli.py b/caltechdata_api/cli.py index e513c13..7563b8a 100644 --- a/caltechdata_api/cli.py +++ b/caltechdata_api/cli.py @@ -417,10 +417,13 @@ def upload_supporting_file(record_id=None): elif filename == "n": break elif (not len(filename) == 0) and (filename[len(filename) - 1] == '/'): - files_name = files[int(filename[0])-1] - filepath = os.path.abspath(files_name) - filepaths.append(filepath) - print("File added successfully") + try: + files_name = files[int(filename[0])-1] + filepath = os.path.abspath(files_name) + filepaths.append(filepath) + print("File added successfully") + except ValueError: + continue elif filename in files: file_size = os.path.getsize(filename) if file_size > 1024 * 1024 * 1024: