Skip to content

Commit

Permalink
precommit
Browse files Browse the repository at this point in the history
  • Loading branch information
Paurikova2 committed Oct 10, 2024
1 parent 13a67fe commit 441f0b4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion libs/dspace-rest-python
9 changes: 5 additions & 4 deletions tools/policy_and_auth/col_add_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down
16 changes: 10 additions & 6 deletions tools/policy_and_auth/policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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:
Expand Down

0 comments on commit 441f0b4

Please sign in to comment.