Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample.py
More file actions
Latest commit
36 lines (28 loc) · 1.66 KB
/
Copy pathexample.py
File metadata and controls
36 lines (28 loc) · 1.66 KB
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
#!/usr/bin/env python3
fromrolib.bundleimport*
fromrolib.manifestimport*
importdatetime
withBundle("test.bundle.zip",mode='w') asro:
ro.manifest.createdOn=datetime.datetime.now().isoformat()
# Stian created the reserarch object (this collection)
stian=Agent(name="Stian Soiland-Reyes", orcid="http://orcid.org/0000-0001-9842-9718")
ro.manifest.createdBy=stian
ro.writestr("hello.txt", "To be, or not to be, that is the question")
hello=ro.manifest.get_aggregate("hello.txt")
# Stian created the hello.txt resource
hello.createdBy=stian
hello.createdOn=datetime.datetime.now().isoformat()
## but someone else authored its content:
shakespeare=Agent(name="William Shakespeare", uri="http://dbpedia.org/page/William_Shakespeare")
hello.authoredBy=shakespeare
hello.authoredOn=datetime.datetime(1604,1,1).isoformat()
# Aggregate an external resource, also different author
quote=ro.manifest.add_aggregate("http://www.folgerdigitaltexts.org/?chapter=5&play=Ham&loc=line-3.1.64")
quote.authoredBy=shakespeare
# Folger Shakespeare Library made the digital representation
folger=Agent(name="Folger Shakespeare Library", uri="http://www.folgerdigitaltexts.org/?chapter=0&?target=credit")
quote.createdBy=folger
# This wikipage (which we didn't need to aggregate) is somewhat about this quote
ro.manifest.add_annotation(about=quote.uri, content="https://en.wikipedia.org/wiki/To_be,_or_not_to_be")
# And also about our hello.txt - even if it doesn't mention it by URL
ro.manifest.add_annotation(about="hello.txt", content="https://en.wikipedia.org/wiki/To_be,_or_not_to_be")