Skip to content

Commit d4205b2

Browse files
committed
Merge pull request #5 from rliebz/test
merging changes that may put master in to an unstable state for the time being
2 parents 8e60018 + 98184d8 commit d4205b2

19 files changed

Lines changed: 313 additions & 177 deletions

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
.vagrant
22
.DS_Store
33
*pyc
4+
.idea/
5+
.cache/
6+
*~

dvn_client/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__author__ = 'RLiebowitz'
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
modified from http://swordapp.github.io/SWORDv2-Profile/SWORDProfile.html#protocoloperations_editingcontent_metadata
4+
-->
5+
<entry xmlns="http://www.w3.org/2005/Atom"
6+
xmlns:dcterms="http://purl.org/dc/terms/">
7+
<!-- some embedded metadata -->
8+
<dcterms:title>Roasting at Home</dcterms:title>
9+
<dcterms:creator>Peets, John</dcterms:creator>
10+
<dcterms:creator>Stumptown, Jane</dcterms:creator>
11+
12+
<!-- Producer with financial or admin responsibility of the data -->
13+
<dcterms:publisher>Coffee Bean State University</dcterms:publisher>
14+
15+
<!-- related publications -->
16+
<dcterms:isReferencedBy holdingsURI="http://dx.doi.org/10.1038/dvn333" agency="DOI"
17+
IDNo="10.1038/dvn333">Peets, J., &amp; Stumptown, J. (2013). Roasting at Home. New England Journal of Coffee, 3(1), 22-34.</dcterms:isReferencedBy>
18+
19+
<!-- production date -->
20+
<dcterms:date>2013-07-11</dcterms:date>
21+
22+
<!-- Other Identifier for the data in this study (or potentially global id if unused) -->
23+
<dcterms:identifier>doi:10.1000/182</dcterms:identifier>
24+
<!-- <dcterms:identifier>hdl:1XXZY.1/XYXZ</dcterms:identifier> -->
25+
26+
<dcterms:description>Considerations before you start roasting your own coffee at home.</dcterms:description>
27+
28+
<!-- keywords -->
29+
<dcterms:subject>coffee</dcterms:subject>
30+
<dcterms:subject>beverage</dcterms:subject>
31+
<dcterms:subject>caffeine</dcterms:subject>
32+
33+
<!-- geographic coverage -->
34+
<dcterms:coverage>United States</dcterms:coverage>
35+
<dcterms:coverage>Canada</dcterms:coverage>
36+
<!-- kind of data -->
37+
<dcterms:type>aggregate data</dcterms:type>
38+
<!-- List of sources of the data collection-->
39+
<dcterms:source>Stumptown, Jane. 2011. Home Roasting. Coffeemill Press.</dcterms:source>
40+
<!-- restrictions -->
41+
<dcterms:rights>Creative Commons CC-BY 3.0 (unported) http://creativecommons.org/licenses/by/3.0/</dcterms:rights>
42+
<!-- related materials -->
43+
<dcterms:relation>Peets, John. 2010. Roasting Coffee at the Coffee Shop. Coffeemill Press</dcterms:relation>
44+
45+
46+
<!-- unsupported fields! -->
47+
<dcterms:abstract>A real abstract!</dcterms:abstract>
48+
<dcterms:bibliographicCitation>Insert Journal Article Citation from OJS</dcterms:bibliographicCitation>
49+
</entry>

dvn_client/src/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
# To change this template, choose Tools | Templates
2-
# and open the template in the editor.
1+
__author__ = 'RLiebowitz'

dvn_client/src/config.py

Lines changed: 0 additions & 4 deletions
This file was deleted.

dvn_client/src/connection.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,16 @@
1616
#local modules
1717
from dataverse import Dataverse
1818

19+
1920
class DvnConnection(object):
2021
# todo add port number
2122
def __init__(self, username, password, host, cert=None, sdUriOverride=None):
2223
# Connection Properties
2324
self.username = username
2425
self.password = password
2526
self.host = host
26-
self.sdUri = "https://{host}/dvn/api/data-deposit/v1/swordv2/service-document".format(host=self.host) if not sdUriOverride else sdUriOverride.format(host=self.host)
27+
self.sdUri = "https://{host}/dvn/api/data-deposit/v1/swordv2/service-document".format(host=self.host) \
28+
if not sdUriOverride else sdUriOverride.format(host=self.host)
2729
self.cert = cert
2830

2931
# Connection Status and SWORD Properties
@@ -39,10 +41,12 @@ def __init__(self, username, password, host, cert=None, sdUriOverride=None):
3941

4042
# todo raise exception if connection fails?
4143
def _connect(self):
42-
self.swordConnection = sword2.Connection(self.sdUri,
43-
user_name = self.username,
44-
user_pass = self.password,
45-
ca_certs = self.cert)
44+
self.swordConnection = sword2.Connection(
45+
service_document_iri=self.sdUri,
46+
user_name=self.username,
47+
user_pass=self.password,
48+
ca_certs=self.cert,
49+
)
4650

4751
self.serviceDocument = self.swordConnection.get_service_document()
4852
self.connected = True

dvn_client/src/dataverse.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
# python base lib modules
55
import pprint
66

7-
#downloaded modules
7+
# downloaded modules
88
from lxml import etree
99

10-
#local modules
10+
# local modules
1111
from study import Study
1212
import utils
1313

@@ -29,14 +29,15 @@ def is_released(self):
2929
collectionInfo,
3030
namespace="http://purl.org/net/sword/terms/state",
3131
tag="dataverseHasBeenReleased",
32-
numberOfElements=1
32+
numberOfElements=1,
3333
).text
3434
return bool(status)
3535

36-
def add_study(self, study):
36+
def add_study(self, study):
37+
# this creates the study AND generates a deposit receipt
3738
depositReceipt = self.connection.swordConnection.create(
39+
col_iri=self.collection.href,
3840
metadata_entry=study.entry,
39-
col_iri=self.collection.href
4041
)
4142

4243
study.hostDataverse = self
@@ -45,6 +46,9 @@ def add_study(self, study):
4546

4647
def delete_study(self, study):
4748
depositReceipt = self.connection.swordConnection.delete(study.editUri)
49+
study.lastDepositReceipt = depositReceipt
50+
51+
# todo: Is this used? Should it be? Other ways to handle this?
4852
study.isDeleted = True
4953

5054
# Note: Functionality removed
@@ -66,13 +70,13 @@ def get_studies(self):
6670
studiesResponse = self.connection.swordConnection.get_resource(self.collection.href)
6771

6872
return [
69-
Study.CreateStudyFromEntryElement(element, hostDataverse=self)
73+
Study.from_entry_element(element, hostDataverse=self)
7074
for element in utils.get_elements(studiesResponse.content, tag='entry')
7175
]
7276
# # get all the entry nodes and parse them into study objects
7377
# studies = []
7478
# for element in utils.get_elements(studiesResponse.content, tag="entry"):
75-
# s = Study.CreateStudyFromEntryElement(element, hostDataverse=self)
79+
# s = Study.from_entry_element(element, hostDataverse=self)
7680
# studies.append(s)
7781
#
7882
# return studies

dvn_client/src/example/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__author__ = 'RLiebowitz'

dvn_client/src/example/config.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
DEFAULT_USERNAME = "rliebz"
2+
DEFAULT_PASSWORD = "other"
3+
DEFAULT_HOST = "dvn-4.hmdc.harvard.edu"
4+
DEFAULT_CERT = "dvn_client/resources/dvn-4.hmdc.harvard.edu"
5+
6+
EXAMPLE_DICT = {
7+
"title" : "ExampleTitle",
8+
"id" : "ExampleID",
9+
"author" : ["ExampleAuthor1", "ExampleAuthor2"],
10+
"producer" : "ExampleProducer",
11+
"date" : "1992-10-04",
12+
"description" : "ExampleDescription",
13+
"abstract" : "ExampleAbstract",
14+
"type" : "ExampleType",
15+
"source" : "ExampleSource",
16+
"restriction" : "ExampleRestriction",
17+
"relation" : "ExampleRelation",
18+
"keyword" : "ExampleKeyword",
19+
"coverage" : "ExampleCoverage",
20+
"publication" : "ExamplePublication",
21+
}
22+
23+
EXAMPLE_FILE = "dvn_client/resources/atom-example.xml"

0 commit comments

Comments
 (0)