From ff794f1856e419b95200c55a04c8cd46945201b3 Mon Sep 17 00:00:00 2001 From: David Michaels Date: Fri, 16 Aug 2024 11:21:57 -0400 Subject: [PATCH] Minor changes to utility/troubleshooting/convenience scripts view-portal-object and update-portal-object. --- dcicutils/scripts/update_portal_object.py | 1 - dcicutils/scripts/view_portal_object.py | 13 ++++++------- pyproject.toml | 2 +- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/dcicutils/scripts/update_portal_object.py b/dcicutils/scripts/update_portal_object.py index 1a73db046..53ea2ecad 100644 --- a/dcicutils/scripts/update_portal_object.py +++ b/dcicutils/scripts/update_portal_object.py @@ -251,7 +251,6 @@ def post_or_patch_or_upsert(portal: Portal, file: str, schema_name: Optional[str elif isinstance(data, list): if debug: _print(f"DEBUG: File ({file}) contains a list of objects of type: {schema_name}") - import pdb ; pdb.set_trace() # noqa data = _impose_special_ordering(data, schema_name) for index, item in enumerate(data): update_function(portal, item, schema_name, file=file, index=index, diff --git a/dcicutils/scripts/view_portal_object.py b/dcicutils/scripts/view_portal_object.py index 4c2ea9b01..cbfbb2aa8 100644 --- a/dcicutils/scripts/view_portal_object.py +++ b/dcicutils/scripts/view_portal_object.py @@ -347,19 +347,18 @@ def get_metadata_for_individual_result_type(uuid: str) -> Optional[dict]: # noq schema_data = response[schema_name] file_name = f"{to_snake_case(schema_name)}.json" file_path = os.path.join(output_directory, file_name) + message_verb = "Writing" if os.path.exists(file_path): + message_verb = "Overwriting" if os.path.isdir(file_path): _print(f"WARNING: Output file already exists as a directory. SKIPPING: {file_path}") continue - if force: - if verbose: - _print(f"Overwriting extant file (per --force option): {file_path}") - else: + if not force: _print(f"Output file already exists: {file_path}") - if (not force) and not yes_or_no(f"Overwrite this file?"): - continue + if not yes_or_no(f"Overwrite this file?"): + continue if verbose: - _print(f"Writing {schema_name} (object{'s' if len(schema_data) != 1 else ''}:" + _print(f"{message_verb} {schema_name} (object{'s' if len(schema_data) != 1 else ''}:" f" {len(schema_data)}) file: {file_path}") with io.open(file_path, "w") as f: json.dump(schema_data, f, indent=4) diff --git a/pyproject.toml b/pyproject.toml index 2c50a4678..e6763c7b9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "dcicutils" -version = "8.14.0.1b5" # TODO: To become 8.14.1 +version = "8.14.0.1b6" # TODO: To become 8.14.1 description = "Utility package for interacting with the 4DN Data Portal and other 4DN resources" authors = ["4DN-DCIC Team "] license = "MIT"