Skip to content

Commit cb04374

Browse files
committed
Merge pull request #5 from samchrisinger/4.0
Some changes
2 parents ef21b64 + 6325ffa commit cb04374

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

dataverse/connection.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ def __init__(self, host, token=None, username=None, password=None):
2626
def auth(self):
2727
return (self.token, None) if self.token else (self.username, self.password)
2828

29+
@property
30+
def has_api_key(self):
31+
return True if self.token else False
32+
2933
def connect(self):
3034
resp = requests.get(self.sd_uri, auth=self.auth)
3135
self.status = resp.status_code
@@ -37,12 +41,17 @@ def get_dataverses(self):
3741
self.connect()
3842

3943
# Dataverse 4.0 beta currently returns collection for "Harvard" DV,
40-
# which the user may not have permissions on. Could cause problems.
44+
# which the user may not have permissions on. Could cause problems.
4145
collections = get_elements(
4246
self.service_document[0],
4347
tag="collection",
4448
)
45-
49+
# removes the Harvard dataverse; this is gross
50+
# also removes the root dataverse (which users do not have read permission on)
51+
def is_not_harvard_or_root(collection):
52+
return (collection.attrib['href'].split('/')[-1] != 'harvard') and (collection.attrib['href'].split('/')[-1] != 'root')
53+
collections = filter(is_not_harvard_or_root, collections)
54+
4655
return [Dataverse(self, col) for col in collections]
4756

4857
def get_dataverse(self, alias):

dataverse/dataverse.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@ def is_released(self):
1717
auth=self.connection.auth,
1818
).content
1919

20-
status = get_element(
20+
status_tag = get_element(
2121
collection_info,
2222
namespace="http://purl.org/net/sword/terms/state",
2323
tag="dataverseHasBeenReleased",
24-
).text
24+
)
25+
status = status_tag.text
2526

2627
return status.lower() == 'true'
2728

0 commit comments

Comments
 (0)