-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget-output.py
48 lines (38 loc) · 1.06 KB
/
get-output.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
import sys
import xml.dom.minidom
from sickle import Sickle
ENDPOINT = 'https://durham-repository.worktribe.com/oaiprovider'
sickle = Sickle(ENDPOINT)
prefix = 'oai:durham-repository.worktribe.com:'
TESTID = '1168839'
rioxx = 'rioxx.xml'
dc = 'dc.xml'
fh1 = open(rioxx, 'w')
fh2 = open(dc, 'w')
def get_rioxx(repo_id):
id = prefix + repo_id
r = sickle.GetRecord(identifier=id, metadataPrefix='rioxx')
print("Got record in rioxx format")
pp = pprint(r)
fh1.write(pp)
fh1.close()
def get_dc(repo_id):
id = prefix + repo_id
r = sickle.GetRecord(identifier=id, metadataPrefix='oai_dc')
print("Got record in oai_dc format")
pp = pprint(r)
fh2.write(pp)
fh2.close()
def pprint(x):
dom = xml.dom.minidom.parseString(str(x))
pretty = dom.toprettyxml()
# print(pretty) #for testing
return pretty
def main():
try:
get_rioxx(sys.argv[1])
get_dc(sys.argv[1])
except IndexError:
print("Usage:\n", sys.argv[0], "WorktribeOutputID")
if __name__ == '__main__':
sys.exit(main()) #