From 441f0b4116949618217ee098fb193fa5eb128090 Mon Sep 17 00:00:00 2001 From: Paurikova2 Date: Thu, 10 Oct 2024 10:04:20 +0200 Subject: [PATCH] precommit --- libs/dspace-rest-python | 2 +- tools/policy_and_auth/col_add_group.py | 9 +++++---- tools/policy_and_auth/policy.py | 16 ++++++++++------ 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/libs/dspace-rest-python b/libs/dspace-rest-python index 5e7e831..36b2f0c 160000 --- a/libs/dspace-rest-python +++ b/libs/dspace-rest-python @@ -1 +1 @@ -Subproject commit 5e7e83163eadb8a28e0ffc0fd786938c3ab5627a +Subproject commit 36b2f0cd3ab1b492ad700df740dca4d3848c0e76 diff --git a/tools/policy_and_auth/col_add_group.py b/tools/policy_and_auth/col_add_group.py index 53176ff..6e01613 100644 --- a/tools/policy_and_auth/col_add_group.py +++ b/tools/policy_and_auth/col_add_group.py @@ -7,14 +7,15 @@ import sys _this_dir = os.path.dirname(os.path.abspath(__file__)) -sys.path.insert(0, os.path.join(_this_dir, "../src")) +path_to_dspace_lib = os.path.join(_this_dir, "../../libs/dspace-rest-python") +sys.path.insert(0, path_to_dspace_lib) +sys.path.insert(0, os.path.join(_this_dir, "../../src")) import dspace # noqa import settings # noqa import project_settings # noqa -from dspace.impl.models import Item # noqa -from dspace.impl.models import Community # noqa +from dspace_rest_client.models import Item, Community # noqa from utils import init_logging, update_settings # noqa _logger = logging.getLogger() @@ -43,7 +44,7 @@ 'submitter_failed': 0 } - start_page = 17 + start_page = 0 for page in range(start_page, 1000): # Get all collections subcolls = dspace_be.client.get_collections(page=page, size=50) diff --git a/tools/policy_and_auth/policy.py b/tools/policy_and_auth/policy.py index fee030d..4b572e6 100644 --- a/tools/policy_and_auth/policy.py +++ b/tools/policy_and_auth/policy.py @@ -7,13 +7,14 @@ import sys _this_dir = os.path.dirname(os.path.abspath(__file__)) -sys.path.insert(0, os.path.join(_this_dir, "../src")) +path_to_dspace_lib = os.path.join(_this_dir, "../../libs/dspace-rest-python") +sys.path.insert(0, os.path.join(_this_dir, "../../src")) import dspace # noqa import settings # noqa import project_settings # noqa -from dspace.impl.models import Item, Community # noqa +from dspace_rest_client.models import Item, Community # noqa from utils import init_logging, update_settings # noqa _logger = logging.getLogger() @@ -47,13 +48,13 @@ def get_all_items(col): """ page = 0 # pagination limit of 100, use 50 - size = 50 + size = 99 items = [] has_more = True while has_more: cur_items = dspace_be.client.get_items_from_collection( col.uuid, page=page, size=size) - if cur_items is None: + if cur_items is None or len(cur_items) == 0: return items items += cur_items page += 1 @@ -114,8 +115,10 @@ def get_all_items(col): f'No {args.bundle_name} bundle for item uuid={item.uuid}') cnt["without_file"] += 1 continue + bundle_resource_policy = dspace_be.client.get_resource_policy(bundle.uuid) cnt["updated"] += 1 - update_resource_policy(dspace_be, None, item, bundle, args.group) + update_resource_policy( + dspace_be, bundle_resource_policy, item, bundle, args.group) if args.policy_of == "item": item_resource_policy = dspace_be.client.get_resource_policy(item.uuid) @@ -125,7 +128,8 @@ def get_all_items(col): cnt["without_item_r_policy"] += 1 continue cnt["updated"] += 1 - update_resource_policy(dspace_be, None, item, bundle, args.group) + update_resource_policy( + dspace_be, item_resource_policy, item, bundle, args.group) if args.policy_of == "bitstream": if bundle is None: