-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
77 lines (49 loc) · 1.82 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# Copyright (c) 2019, Hrafn Malmquist
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
from dspace_rest_client import DSpaceRestClient, Metadata, Collection
import datetime
# TODO find object by name, or search string
# TODO find object by size, age, number of bitstreams,
d = DSpaceRestClient(user='[email protected]',
password='dspace',
rest_url='https://demo.dspace.org/rest',
verify_ssl=False,
load_item_metadata=True)
# items = d.get_items(limit=5)
#print(len(items))
#print(d.find_community('Sample'))
t = datetime.date(2019, 3, 18).timetuple()
#for c in d.find_item_by('uuid', '3'):
# print(c)
for i in d.get_items():
if(i.lastModified > t):
print(i)
#for c in d.get_communities():
# if c.countItems > 10:
# print(c)
#for cl in c.get_collections():
# print(cl)
'''comm = d.get_top_communities()
print(comm[1].name)
print(comm[1].collections)
print(len(comm))'''
# print(items[0]['handle'])
#for item in d.get_items():
# for m in item.metadata:
# print(m)
# metadata = Metadata('dc.subject', 'Coldplay', 'en_GB')
# metadata2 = Metadata('dc.subject', 'Led Zeppelin', 'en_GB')
# print(json.dumps([metadata.__dict__]))
# print([str(m) for m in [metadata]])
# items[0].add_metadata([metadata, metadata2])
#for m in items[0].metadata:
# print(m)
#d.update_record(items[0]['handle'], [d.format_metadata('dc.subject', 'interesting5')])
# d.add_metadata(items[0]['handle'], [d.format_metadata('dc.subject', 'go-kart')])
# for i in items:
# print(json.dumps(d.get_metadata(i['handle']), indent=4, sort_keys=True))
# print(json.dumps(d.get_items(), indent=4, sort_keys=True))
d.logout()