Permalink
Browse files

Merge pull request #32 from Scifabric/python3-support

Python3 support
  • Loading branch information...
2 parents 4fdadf6 + 77c71e2 commit d86736786c9d77533cb41b05e34bd841b8aeac78 @teleyinex teleyinex committed Sep 12, 2017
Showing with 29 additions and 13 deletions.
  1. +4 −0 .gitignore
  2. +3 −1 .travis.yml
  3. +7 −0 README.rst
  4. +14 −11 pbclient/__init__.py
  5. +1 −1 setup.py
View
@@ -15,3 +15,7 @@ pybossa_client.egg-info/
.noseids
+.coverage
+.ropeproject/
+env3
+
View
@@ -2,8 +2,10 @@ sudo: false
language: python
python:
- "2.7"
+ - "3.5"
+ - "3.6"
install:
- - pip install -r requirements.txt --use-mirrors
+ - pip install -r requirements.txt
- pip install rednose
- pip install nose
- pip install mock
View
@@ -4,6 +4,13 @@
:target: https://pypi.python.org/pypi/pybossa-client
.. image:: https://img.shields.io/pypi/dm/pybossa-client.svg
:target: https://pypi.python.org/pypi/pybossa-client
+.. image:: https://img.shields.io/badge/python-2.7-green.svg
+ :target: https://pypi.python.org/pypi/pybossa-client
+.. image:: https://img.shields.io/badge/python-3.5-blue.svg
+ :target: https://pypi.python.org/pypi/pybossa-client
+.. image:: https://img.shields.io/badge/python-3.6-orange.svg
+ :target: https://pypi.python.org/pypi/pybossa-client
+
Dead simple Python client for PYBOSSA
=====================================
View
@@ -8,11 +8,14 @@
:license: MIT
"""
-_opts = dict()
-
+from __future__ import division
import requests
import json
+
+_opts = dict()
+
+
OFFSET_WARNING = """
INFO: you can use keyset pagination to get faster responses from the server.
To learn more, please visit:
@@ -54,7 +57,7 @@ def _pybossa_req(method, domain, id=None, payload=None, params={},
elif method == 'delete':
r = requests.delete(url, params=params, headers=headers,
data=json.dumps(payload))
- if r.status_code / 100 == 2:
+ if r.status_code // 100 == 2:
if r.text and r.text != '""':
return json.loads(r.text)
else:
@@ -179,7 +182,7 @@ def get_projects(limit=100, offset=0, last_id=None):
if last_id is not None:
params = dict(limit=limit, last_id=last_id)
else:
- print OFFSET_WARNING
+ print(OFFSET_WARNING)
params = dict(limit=limit, offset=offset)
try:
res = _pybossa_req('get', 'project',
@@ -310,7 +313,7 @@ def get_categories(limit=20, offset=0, last_id=None):
params = dict(limit=limit, last_id=last_id)
else:
params = dict(limit=limit, offset=offset)
- print OFFSET_WARNING
+ print(OFFSET_WARNING)
try:
res = _pybossa_req('get', 'category',
params=params)
@@ -437,7 +440,7 @@ def get_tasks(project_id, limit=100, offset=0, last_id=None):
params = dict(limit=limit, last_id=last_id)
else:
params = dict(limit=limit, offset=offset)
- print OFFSET_WARNING
+ print(OFFSET_WARNING)
params['project_id'] = project_id
try:
res = _pybossa_req('get', 'task',
@@ -563,7 +566,7 @@ def get_taskruns(project_id, limit=100, offset=0, last_id=None):
params = dict(limit=limit, last_id=last_id)
else:
params = dict(limit=limit, offset=offset)
- print OFFSET_WARNING
+ print(OFFSET_WARNING)
params['project_id'] = project_id
try:
res = _pybossa_req('get', 'taskrun',
@@ -632,7 +635,7 @@ def get_results(project_id, limit=100, offset=0, last_id=None):
params = dict(limit=limit, last_id=last_id)
else:
params = dict(limit=limit, offset=offset)
- print OFFSET_WARNING
+ print(OFFSET_WARNING)
params['project_id'] = project_id
try:
res = _pybossa_req('get', 'result',
@@ -687,8 +690,8 @@ def update_result(result):
def _forbidden_attributes(obj):
"""Return the object without the forbidden attributes."""
- for key in obj.data.keys():
- if key in obj.reserved_keys.keys():
+ for key in list(obj.data.keys()):
+ if key in list(obj.reserved_keys.keys()):
obj.data.pop(key)
return obj
@@ -748,7 +751,7 @@ def get_helping_materials(project_id, limit=100, offset=0, last_id=None):
params = dict(limit=limit, last_id=last_id)
else:
params = dict(limit=limit, offset=offset)
- print OFFSET_WARNING
+ print(OFFSET_WARNING)
params['project_id'] = project_id
try:
res = _pybossa_req('get', 'helpingmaterial',
View
@@ -2,7 +2,7 @@
setup(
name='pybossa-client',
- version='1.2.1',
+ version='2.0.0',
packages=find_packages(),
install_requires=['requests>=0.13.0'],
# metadata for upload to PyPI

0 comments on commit d867367

Please sign in to comment.