Skip to content

Commit ace1848

Browse files
committed
minor update as part of release preparations
1 parent 2bcf0c5 commit ace1848

9 files changed

Lines changed: 51 additions & 77 deletions

File tree

.gitignore

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,8 @@ venv_home/
1111
.env/
1212

1313
# Personal
14-
src/pyDataverse/docs/build
15-
src/pyDataverse/docs/Makefile
16-
notes.md
17-
notes_*.md
18-
snippets.md
19-
stash_*.*
20-
src/dev/
21-
src/testing.py
14+
notes*.md
15+
stash*.*
2216

2317
# Distribution / packaging
2418
build/
@@ -30,10 +24,12 @@ MANIFEST
3024

3125
# Documentation
3226
docs/build/
27+
src/pyDataverse/docs/build
28+
src/pyDataverse/docs/Makefile
3329

3430
# Unit test / coverage reports
3531
.tox
36-
htmlcov/
32+
docs/coverage_html/
3733
.coverage
3834
.coverage.*
3935
.*cache

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,4 @@ notifications:
4848
email:
4949
recipients:
5050
- stefan.kasberger@univie.ac.at
51-
on_success: never
52-
on_failure: always
51+
on_success: change

setup.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# !/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
"""Find out more at https://github.com/AUSSDA/pyDataverse."""
14
import codecs
25
import os
36
import re

src/pyDataverse/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# !/usr/bin/env python
22
# -*- coding: utf-8 -*-
3+
"""Find out more at https://github.com/AUSSDA/pyDataverse."""
34
from __future__ import absolute_import
45

56
from requests.packages import urllib3
6-
urllib3.disable_warnings() # noqa
7+
urllib3.disable_warnings() # noqa
78

89
"""pyDataverse
910
Copyright 2019 Stefan Kasberger
@@ -17,5 +18,5 @@
1718
__license__ = 'MIT License'
1819
__version__ = '0.1.0'
1920
__url__ = 'https://github.com/AUSSDA/pyDataverse'
20-
__download_url__ = 'https://pypi.python.org/pypi/python-twitter'
21+
__download_url__ = 'https://pypi.python.org/pypi/pyDataverse'
2122
__description__ = 'A Python wrapper around the Dataverse API'

src/pyDataverse/api.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# coding: utf-8
1+
# !/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
"""Find out more at https://github.com/AUSSDA/pyDataverse."""
24
from __future__ import absolute_import
35
from datetime import datetime
46
import json
@@ -165,20 +167,18 @@ def make_get_request(self, query_str, params=None, auth=False):
165167
)
166168

167169
def make_post_request(self, query_str, metadata=None, auth=False,
168-
headers=None, params=None):
170+
params=None):
169171
"""Make a POST request.
170172
171173
Parameters
172174
----------
173175
query_str : string
174176
Query string for the request. Will be concatenated to
175177
`native_api_base_url`.
176-
data : type
177-
Description of parameter `data`.
178+
metadata : string
179+
Metadata as a json-formatted string. Defaults to `None`.
178180
auth : bool
179181
Should an api token be sent in the request. Defaults to `False`.
180-
headers : dict
181-
Data for the request header.
182182
params : dict
183183
Dictionary of parameters to be passed with the request.
184184
Defaults to `None`.
@@ -189,8 +189,6 @@ def make_post_request(self, query_str, metadata=None, auth=False,
189189
Response object of requests library.
190190
191191
"""
192-
# TODO: update to docstring the data data-type and description.
193-
# TODO: update to docstring the headers data-type and description.
194192
url = '{0}{1}'.format(self.native_api_base_url, query_str)
195193
if auth:
196194
if self.api_token:
@@ -207,7 +205,6 @@ def make_post_request(self, query_str, metadata=None, auth=False,
207205
resp = post(
208206
url,
209207
data=metadata,
210-
headers=headers,
211208
params=params
212209
)
213210
if resp.status_code == 401:
@@ -535,7 +532,7 @@ def create_dataset(self, dataverse, metadata, auth=True):
535532
dataverse : string
536533
Alias of dataverse to which the dataset should be added to.
537534
metadata : string
538-
Dataverse metadata as json-formatted string.
535+
Metadata of the Dataset as a json-formatted string.
539536
540537
Returns
541538
-------

src/pyDataverse/exceptions.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# !/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
"""Find out more at https://github.com/AUSSDA/pyDataverse."""
14
from __future__ import absolute_import
25

36

@@ -38,7 +41,7 @@ class ApiAuthorizationError(OperationFailedError):
3841

3942

4043
class DataverseNotEmptyError(OperationFailedError):
41-
"""Raised when a Dataverse cannot be found."""
44+
"""Raised when a Dataverse has accessioned Datasets."""
4245

4346
pass
4447

@@ -56,6 +59,6 @@ class DatasetNotFoundError(OperationFailedError):
5659

5760

5861
class DatafileNotFoundError(OperationFailedError):
59-
"""Raised when a Dataset cannot be found."""
62+
"""Raised when a Datafile cannot be found."""
6063

6164
pass

src/pyDataverse/utils.py

Lines changed: 25 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# coding: utf-8
1+
# !/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
"""Find out more at https://github.com/AUSSDA/pyDataverse."""
24
from __future__ import absolute_import
3-
4-
import csv
55
import json
66

77

@@ -14,12 +14,12 @@ def json_to_dict(data):
1414
Parameters
1515
----------
1616
data : string
17-
`data` as JSON-formatted string.
17+
Data as a json-formatted string.
1818
1919
Returns
2020
-------
2121
dict
22-
`data` represented as dict().
22+
Data as Python Dictionary.
2323
2424
"""
2525
try:
@@ -37,12 +37,12 @@ def dict_to_json(data):
3737
Parameters
3838
----------
3939
data : dict
40-
`data` represented as dict().
40+
Data as Python Dictionary.
4141
4242
Returns
4343
-------
4444
string
45-
`data` as JSON-formatted string
45+
Data as a json-formatted string.
4646
4747
"""
4848
try:
@@ -52,20 +52,20 @@ def dict_to_json(data):
5252

5353

5454
def read_file(filename, mode='r'):
55-
"""Read in data from a file.
55+
"""Read in a file.
5656
5757
Parameters
5858
----------
59-
filename : type
60-
Description of parameter `filename`.
59+
filename : string
60+
Filename with full path.
6161
mode : string
62-
Read mode of file. Default is `r`. See more at
62+
Read mode of file. Defaults to `r`. See more at
6363
https://docs.python.org/3.5/library/functions.html#open
6464
6565
Returns
6666
-------
6767
string
68-
Returns the whole content as string.
68+
Returns data as string.
6969
7070
"""
7171
try:
@@ -78,44 +78,44 @@ def read_file(filename, mode='r'):
7878
raise e
7979

8080

81-
def write_file(filename, string, mode='w'):
81+
def write_file(filename, data, mode='w'):
8282
"""Write data in a file.
8383
8484
Parameters
8585
----------
8686
filename : string
87-
Full filename with path of file.
88-
string : string
89-
String of data to be written.
87+
Filename with full path.
88+
data : string
89+
Data to be stored.
9090
mode : string
91-
Read mode of file. Default is `w`. See more at
91+
Read mode of file. Defaults to `w`. See more at
9292
https://docs.python.org/3.5/library/functions.html#open
9393
9494
"""
9595
try:
9696
with open(filename, mode) as f:
97-
f.write(string)
97+
f.write(data)
9898
except IOError:
9999
print('An error occured trying to write the file {}.'.format(filename))
100100
except Exception as e:
101101
raise e
102102

103103

104104
def read_file_json(filename):
105-
"""Read in JSON file.
105+
"""Read in a json file.
106106
107107
See more about the json module at
108108
https://docs.python.org/3.5/library/json.html
109109
110110
Parameters
111111
----------
112112
filename : string
113-
Full filename with path of file.
113+
Filename with full path.
114114
115115
Returns
116116
-------
117117
dict
118-
Data represented as a dict().
118+
Data as a json-formatted string.
119119
120120
"""
121121
try:
@@ -125,42 +125,17 @@ def read_file_json(filename):
125125

126126

127127
def write_file_json(filename, data, mode='w'):
128-
"""Write dict() in a JSON file.
128+
"""Write data to a json file.
129129
130130
Parameters
131131
----------
132132
filename : string
133-
Full filename with path of file.
133+
Filename with full path.
134134
data : dict
135-
Data to be written in the JSON file.
135+
Data to be written in the json file.
136136
mode : string
137-
Write mode of file. Default is `w`. See more at
137+
Write mode of file. Defaults to `w`. See more at
138138
https://docs.python.org/3/library/functions.html#open
139139
140140
"""
141141
write_file(filename, dict_to_json(data), mode)
142-
143-
144-
def read_file_csv(filename):
145-
"""Read in CSV file.
146-
147-
See more about csv.reader() at https://docs.python.org/3.5/library/csv.html
148-
149-
Parameters
150-
----------
151-
filename : string
152-
Full filename with path of file.
153-
154-
Returns
155-
-------
156-
reader
157-
Reader object, which can be iterated over.
158-
159-
"""
160-
try:
161-
with open(filename, newline='') as csvfile:
162-
return csv.reader(csvfile, delimiter=',', quotechar='"')
163-
except Exception as e:
164-
raise e
165-
finally:
166-
csvfile.close()

tests/test_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
if 'BASE_URL' in os.environ:
2424
BASE_URL = os.environ['BASE_URL']
2525
else:
26-
print('ERROR: Environment variable BASE_URL for test missing.')
26+
print('ERROR: Environment variable BASE_URL for test missing.')
2727

2828

2929
class TestApiConnect(object):

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = py36,coverage,packaging,docs,flake8
2+
envlist = flake8,coverage,packaging,docs,py36
33
skip_missing_interpreters = True
44
ignore_basepython_conflict = True
55

0 commit comments

Comments
 (0)