From d34cc0579ceaffb1243dd51f9fd87e55355e7bef Mon Sep 17 00:00:00 2001 From: Neil Massey Date: Wed, 23 Oct 2024 08:11:00 +0100 Subject: [PATCH] Removed delete and dellist commands for now --- nlds_client/nlds_client.py | 286 ++++++++++++++++++------------------- 1 file changed, 143 insertions(+), 143 deletions(-) diff --git a/nlds_client/nlds_client.py b/nlds_client/nlds_client.py index 3271a8a..7798471 100755 --- a/nlds_client/nlds_client.py +++ b/nlds_client/nlds_client.py @@ -572,65 +572,65 @@ def get( raise click.UsageError(re) -"""delete files command""" - - -@nlds_client.command("delete", help=f"Delete a single file.{user_help_text}") -@click.option( - "-u", "--user", default=None, type=str, help="The username to delete a file for." -) -@click.option( - "-g", "--group", default=None, type=str, help="The group to delete a file for." -) -@click.option( - "-A", - "--groupall", - default=False, - is_flag=True, - help="Get files that belong to a group, rather than a single " "user", -) -@click.option( - "-l", - "--label", - default=None, - type=str, - help="The label of the holding to delete the file from. This " - "can be a regular expression (regex).", -) -@click.option( - "-b", - "--job_label", - default=None, - type=str, - help="An optional label for the DEL job, that can be viewed when " - "using the stat command", -) -@click.option( - "-i", - "--holding_id", - default=None, - type=int, - help="The id of the holding to delete the file from.", -) -@click.option( - "-j", "--json", default=False, type=bool, help="Output the result as JSON." -) -@click.argument("filepath", type=str) -def delete(filepath, user, group, groupall, job_label, label, holding_id, json): - try: - response = del_filelist( - [filepath], user, group, groupall, job_label, label, holding_id - ) - if json: - click.echo(response) - else: - print_response(response) - except ConnectionError as ce: - raise click.UsageError(ce) - except AuthenticationError as ae: - raise click.UsageError(ae) - except RequestError as re: - raise click.UsageError(re) +# """delete files command""" + + +# @nlds_client.command("delete", help=f"Delete a single file.{user_help_text}") +# @click.option( +# "-u", "--user", default=None, type=str, help="The username to delete a file for." +# ) +# @click.option( +# "-g", "--group", default=None, type=str, help="The group to delete a file for." +# ) +# @click.option( +# "-A", +# "--groupall", +# default=False, +# is_flag=True, +# help="Get files that belong to a group, rather than a single " "user", +# ) +# @click.option( +# "-l", +# "--label", +# default=None, +# type=str, +# help="The label of the holding to delete the file from. This " +# "can be a regular expression (regex).", +# ) +# @click.option( +# "-b", +# "--job_label", +# default=None, +# type=str, +# help="An optional label for the DEL job, that can be viewed when " +# "using the stat command", +# ) +# @click.option( +# "-i", +# "--holding_id", +# default=None, +# type=int, +# help="The id of the holding to delete the file from.", +# ) +# @click.option( +# "-j", "--json", default=False, type=bool, help="Output the result as JSON." +# ) +# @click.argument("filepath", type=str) +# def delete(filepath, user, group, groupall, job_label, label, holding_id, json): +# try: +# response = del_filelist( +# [filepath], user, group, groupall, job_label, label, holding_id +# ) +# if json: +# click.echo(response) +# else: +# print_response(response) +# except ConnectionError as ce: +# raise click.UsageError(ce) +# except AuthenticationError as ae: +# raise click.UsageError(ae) +# except RequestError as re: +# raise click.UsageError(re) """Put filelist command""" @@ -805,90 +805,90 @@ def getlist( raise click.UsageError(re) -"""dellist files command""" - - -@nlds_client.command( - "dellist", help=f"Delete a number of files specified in a list.{user_help_text}" -) -@click.option( - "-u", "--user", default=None, type=str, help="The username to delete files for." -) -@click.option( - "-g", "--group", default=None, type=str, help="The group to delete files for." -) -@click.option( - "-A", - "--groupall", - default=False, - is_flag=True, - help="Get files that belong to a group, rather than a single " "user", -) -@click.option( - "-l", - "--label", - default=None, - type=str, - help="The label of the holding to delete files from. This " - "can be a regular expression (regex).", -) -@click.option( - "-b", - "--job_label", - default=None, - type=str, - help="An optional label for the DELLIST job, that can be viewed " - "when using the stat command", -) -@click.option( - "-i", - "--holding_id", - default=None, - type=int, - help="The id of the holding to delete the file from.", -) -@click.option( - "-j", "--json", default=False, type=bool, help="Output the result as JSON." -) -@click.argument("filelist", type=str) -def dellist(filelist, user, group, groupall, job_label, label, holding_id, json): - # read the filelist from the file - try: - fh = open(filelist) - files = fh.readlines() - fh.close() - except FileNotFoundError as fe: - raise click.UsageError(fe) - - try: - req_details = format_request_details( - user, group, groupall=groupall, label=label, holding_id=holding_id - ) - response = del_filelist( - files, user, group, groupall, job_label, label, holding_id - ) - if response["success"]: - if json: - click.echo(response) - else: - print_list(response, req_details) - else: - fail_string = "Failed to delete file(s) with " - fail_string += req_details - if "failure" in response["details"]: - fail_string += "\nReason: " + response["details"]["failure"] - raise click.UsageError(fail_string) - - if json: - click.echo(response) - else: - print_response(response) - except ConnectionError as ce: - raise click.UsageError(ce) - except AuthenticationError as ae: - raise click.UsageError(ae) - except RequestError as re: - raise click.UsageError(re) +# """dellist files command""" + + +# @nlds_client.command( +# "dellist", help=f"Delete a number of files specified in a list.{user_help_text}" +# ) +# @click.option( +# "-u", "--user", default=None, type=str, help="The username to delete files for." +# ) +# @click.option( +# "-g", "--group", default=None, type=str, help="The group to delete files for." +# ) +# @click.option( +# "-A", +# "--groupall", +# default=False, +# is_flag=True, +# help="Get files that belong to a group, rather than a single " "user", +# ) +# @click.option( +# "-l", +# "--label", +# default=None, +# type=str, +# help="The label of the holding to delete files from. This " +# "can be a regular expression (regex).", +# ) +# @click.option( +# "-b", +# "--job_label", +# default=None, +# type=str, +# help="An optional label for the DELLIST job, that can be viewed " +# "when using the stat command", +# ) +# @click.option( +# "-i", +# "--holding_id", +# default=None, +# type=int, +# help="The id of the holding to delete the file from.", +# ) +# @click.option( +# "-j", "--json", default=False, type=bool, help="Output the result as JSON." +# ) +# @click.argument("filelist", type=str) +# def dellist(filelist, user, group, groupall, job_label, label, holding_id, json): +# # read the filelist from the file +# try: +# fh = open(filelist) +# files = fh.readlines() +# fh.close() +# except FileNotFoundError as fe: +# raise click.UsageError(fe) + +# try: +# req_details = format_request_details( +# user, group, groupall=groupall, label=label, holding_id=holding_id +# ) +# response = del_filelist( +# files, user, group, groupall, job_label, label, holding_id +# ) +# if response["success"]: +# if json: +# click.echo(response) +# else: +# print_list(response, req_details) +# else: +# fail_string = "Failed to delete file(s) with " +# fail_string += req_details +# if "failure" in response["details"]: +# fail_string += "\nReason: " + response["details"]["failure"] +# raise click.UsageError(fail_string) + +# if json: +# click.echo(response) +# else: +# print_response(response) +# except ConnectionError as ce: +# raise click.UsageError(ce) +# except AuthenticationError as ae: +# raise click.UsageError(ae) +# except RequestError as re: +# raise click.UsageError(re) """List (holdings) command"""