[Python-modules-commits] [python-kanboard] 01/10: New upstream version 1.0.1
ChangZhuo Chen
czchen at moszumanska.debian.org
Tue Feb 28 15:37:50 UTC 2017
This is an automated email from the git hooks/post-receive script.
czchen pushed a commit to branch master
in repository python-kanboard.
commit 19dea84f5f0c857a99d1e1281cf303534768812c
Author: ChangZhuo Chen (陳昌倬) <czchen at debian.org>
Date: Tue Feb 28 23:12:22 2017 +0800
New upstream version 1.0.1
---
.travis.yml | 18 ++++++
AUTHORS | 1 +
ChangeLog | 27 +++++++++
LICENSE | 21 +++++++
PKG-INFO | 82 +++++++++++++++++++++++++
README.rst | 62 +++++++++++++++++++
kanboard.egg-info/PKG-INFO | 82 +++++++++++++++++++++++++
kanboard.egg-info/SOURCES.txt | 22 +++++++
kanboard.egg-info/dependency_links.txt | 1 +
kanboard.egg-info/not-zip-safe | 1 +
kanboard.egg-info/pbr.json | 1 +
kanboard.egg-info/requires.txt | 2 +
kanboard.egg-info/top_level.txt | 1 +
kanboard/__init__.py | 1 +
kanboard/client.py | 106 +++++++++++++++++++++++++++++++++
kanboard/exceptions.py | 2 +
kanboard/tests/__init__.py | 0
kanboard/tests/test_kanboard.py | 45 ++++++++++++++
requirements.txt | 2 +
setup.cfg | 29 +++++++++
setup.py | 8 +++
test-requirements.txt | 4 ++
tox.ini | 21 +++++++
23 files changed, 539 insertions(+)
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..4be31c8
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,18 @@
+language: python
+python:
+ - '3.5'
+install:
+ - pip install --upgrade setuptools
+ - pip install --upgrade pip
+ - pip install tox
+script:
+ - tox
+deploy:
+ provider: pypi
+ user: fguillot
+ password:
+ secure: d9LwxCuaY/gpaGtFBbtL+Fya2Bw7o2HGw8jUTqOJwGdMCpWgnKk7HwBb0p9Xehu+xsaqhV3+z36OHpyESNQBgJMb78J8eyGbuNRrIxB+Lo6PRExHhq+n2ZXaCVu93Z0g400EyOVrNr74XYLfFHqSE5Uw2pD+SEzFQTrnDuZTY28lfT0glLvYW0zdBVNiWQaTqAoMUo+n//D7gE5HCrGmLhapvRljAULzMSg+fkzbHb9uUVNfQiur7O+l67egegfnIJms6eaeHzx3dikxWdJuJUc+i0/QIBb0UiLwea8o/syOpYqscmwpeD2smGdA9Go+Cgr0kfRKKO/3QzEPOHgxMc3fxVLntR+mgyb4qfSIIMEtNQ/WdW2+AtyBoxSK5sERwPiaSLP3zVvF/sPs2DTDSvtAl5MlPorEu5P9hJeuK4RE8MlOFNsAzN/cTbXVFwkDSzKfprBA+wspcii+x84cp3PkDgRXUdXU [...]
+ on:
+ tags: true
+ distributions: sdist bdist_wheel
+ repo: kanboard/kanboard-api-python
diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..639fb28
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1 @@
+Frederic Guillot <fred at kanboard.net>
diff --git a/ChangeLog b/ChangeLog
new file mode 100644
index 0000000..9662ce0
--- /dev/null
+++ b/ChangeLog
@@ -0,0 +1,27 @@
+CHANGES
+=======
+
+1.0.1
+-----
+
+* Upgrade setuptools and pip on travis
+* Update tox.ini
+* Switch to pbr
+* Update password for pypi deployment config
+* Add travis pypi deployment config
+* Remove Dockerfile
+* Add travis badge
+* Improve travis.yml
+* Add more Python versions in travis.yml
+* Add travis.yml
+* Handle exceptions
+* Add tox.ini and unit tests
+* Add Dockerfile
+
+1.0.0
+-----
+
+* Add setup.py
+* Convert README to RST format
+* Add license file
+* First commit
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..4d154e8
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2016 Frederic Guillot
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/PKG-INFO b/PKG-INFO
new file mode 100644
index 0000000..fe8dc71
--- /dev/null
+++ b/PKG-INFO
@@ -0,0 +1,82 @@
+Metadata-Version: 1.1
+Name: kanboard
+Version: 1.0.1
+Summary: Kanboard API client
+Home-page: https://github.com/kanboard/kanboard-api-python
+Author: Frédéric Guillot
+Author-email: fred at kanboard.net
+License: MIT
+Description: ==============================
+ Python API Client for Kanboard
+ ==============================
+
+ .. image:: https://travis-ci.org/kanboard/kanboard-api-python.svg?branch=master
+ :target: https://travis-ci.org/kanboard/kanboard-api-python
+
+ Minimalist Kanboard Python client.
+
+ - Author: Frédéric Guillot
+ - License: MIT
+
+ Installation
+ ============
+
+ .. code-block:: bash
+
+ pip install kanboard
+
+
+ This library is compatible with Python 2.7, Python 3.4 and 3.5.
+
+ Examples
+ ========
+
+ The methods and arguments are the same as the JSON-RPC procedures described in the `official documentation <http://kanboard.net/documentation/api-json-rpc>`_.
+
+ Python methods are dynamically mapped to the API procedures. You must use named arguments.
+
+ Create a new team project
+ -------------------------
+
+ .. code-block:: python
+
+ from kanboard import Kanboard
+
+ kb = Kanboard('http://localhost/jsonrpc.php', 'jsonrpc', 'your_api_token')
+ project_id = kb.create_project(name='My project')
+
+
+ Authenticate as user
+ --------------------
+
+ .. code-block:: python
+
+ from kanboard import Kanboard
+
+ kb = Kanboard('http://localhost/jsonrpc.php', 'admin', 'admin')
+ kb.get_my_projects()
+
+ Create a new task
+ -----------------
+
+ .. code-block:: python
+
+ from kanboard import Kanboard
+
+ kb = Kanboard('http://localhost/jsonrpc.php', 'jsonrpc', 'your_api_token')
+ project_id = kb.create_project(name='My project')
+ task_id = kb.create_task(project_id=project_id, title='My task title')
+
+ See the `official API documentation <https://kanboard.net/documentation/api-json-rpc>`_ for the complete list of methods and arguments.
+
+
+Keywords: kanboard
+api
+Platform: UNKNOWN
+Classifier: Intended Audience :: Developers
+Classifier: Intended Audience :: Information Technology
+Classifier: License :: OSI Approved :: MIT License
+Classifier: Operating System :: OS Independent
+Classifier: Programming Language :: Python
+Classifier: Programming Language :: Python :: 2
+Classifier: Programming Language :: Python :: 3
diff --git a/README.rst b/README.rst
new file mode 100644
index 0000000..df8a988
--- /dev/null
+++ b/README.rst
@@ -0,0 +1,62 @@
+==============================
+Python API Client for Kanboard
+==============================
+
+.. image:: https://travis-ci.org/kanboard/kanboard-api-python.svg?branch=master
+ :target: https://travis-ci.org/kanboard/kanboard-api-python
+
+Minimalist Kanboard Python client.
+
+- Author: Frédéric Guillot
+- License: MIT
+
+Installation
+============
+
+.. code-block:: bash
+
+ pip install kanboard
+
+
+This library is compatible with Python 2.7, Python 3.4 and 3.5.
+
+Examples
+========
+
+The methods and arguments are the same as the JSON-RPC procedures described in the `official documentation <http://kanboard.net/documentation/api-json-rpc>`_.
+
+Python methods are dynamically mapped to the API procedures. You must use named arguments.
+
+Create a new team project
+-------------------------
+
+.. code-block:: python
+
+ from kanboard import Kanboard
+
+ kb = Kanboard('http://localhost/jsonrpc.php', 'jsonrpc', 'your_api_token')
+ project_id = kb.create_project(name='My project')
+
+
+Authenticate as user
+--------------------
+
+.. code-block:: python
+
+ from kanboard import Kanboard
+
+ kb = Kanboard('http://localhost/jsonrpc.php', 'admin', 'admin')
+ kb.get_my_projects()
+
+Create a new task
+-----------------
+
+.. code-block:: python
+
+ from kanboard import Kanboard
+
+ kb = Kanboard('http://localhost/jsonrpc.php', 'jsonrpc', 'your_api_token')
+ project_id = kb.create_project(name='My project')
+ task_id = kb.create_task(project_id=project_id, title='My task title')
+
+See the `official API documentation <https://kanboard.net/documentation/api-json-rpc>`_ for the complete list of methods and arguments.
diff --git a/kanboard.egg-info/PKG-INFO b/kanboard.egg-info/PKG-INFO
new file mode 100644
index 0000000..fe8dc71
--- /dev/null
+++ b/kanboard.egg-info/PKG-INFO
@@ -0,0 +1,82 @@
+Metadata-Version: 1.1
+Name: kanboard
+Version: 1.0.1
+Summary: Kanboard API client
+Home-page: https://github.com/kanboard/kanboard-api-python
+Author: Frédéric Guillot
+Author-email: fred at kanboard.net
+License: MIT
+Description: ==============================
+ Python API Client for Kanboard
+ ==============================
+
+ .. image:: https://travis-ci.org/kanboard/kanboard-api-python.svg?branch=master
+ :target: https://travis-ci.org/kanboard/kanboard-api-python
+
+ Minimalist Kanboard Python client.
+
+ - Author: Frédéric Guillot
+ - License: MIT
+
+ Installation
+ ============
+
+ .. code-block:: bash
+
+ pip install kanboard
+
+
+ This library is compatible with Python 2.7, Python 3.4 and 3.5.
+
+ Examples
+ ========
+
+ The methods and arguments are the same as the JSON-RPC procedures described in the `official documentation <http://kanboard.net/documentation/api-json-rpc>`_.
+
+ Python methods are dynamically mapped to the API procedures. You must use named arguments.
+
+ Create a new team project
+ -------------------------
+
+ .. code-block:: python
+
+ from kanboard import Kanboard
+
+ kb = Kanboard('http://localhost/jsonrpc.php', 'jsonrpc', 'your_api_token')
+ project_id = kb.create_project(name='My project')
+
+
+ Authenticate as user
+ --------------------
+
+ .. code-block:: python
+
+ from kanboard import Kanboard
+
+ kb = Kanboard('http://localhost/jsonrpc.php', 'admin', 'admin')
+ kb.get_my_projects()
+
+ Create a new task
+ -----------------
+
+ .. code-block:: python
+
+ from kanboard import Kanboard
+
+ kb = Kanboard('http://localhost/jsonrpc.php', 'jsonrpc', 'your_api_token')
+ project_id = kb.create_project(name='My project')
+ task_id = kb.create_task(project_id=project_id, title='My task title')
+
+ See the `official API documentation <https://kanboard.net/documentation/api-json-rpc>`_ for the complete list of methods and arguments.
+
+
+Keywords: kanboard
+api
+Platform: UNKNOWN
+Classifier: Intended Audience :: Developers
+Classifier: Intended Audience :: Information Technology
+Classifier: License :: OSI Approved :: MIT License
+Classifier: Operating System :: OS Independent
+Classifier: Programming Language :: Python
+Classifier: Programming Language :: Python :: 2
+Classifier: Programming Language :: Python :: 3
diff --git a/kanboard.egg-info/SOURCES.txt b/kanboard.egg-info/SOURCES.txt
new file mode 100644
index 0000000..a8e44f1
--- /dev/null
+++ b/kanboard.egg-info/SOURCES.txt
@@ -0,0 +1,22 @@
+.travis.yml
+AUTHORS
+ChangeLog
+LICENSE
+README.rst
+requirements.txt
+setup.cfg
+setup.py
+test-requirements.txt
+tox.ini
+kanboard/__init__.py
+kanboard/client.py
+kanboard/exceptions.py
+kanboard.egg-info/PKG-INFO
+kanboard.egg-info/SOURCES.txt
+kanboard.egg-info/dependency_links.txt
+kanboard.egg-info/not-zip-safe
+kanboard.egg-info/pbr.json
+kanboard.egg-info/requires.txt
+kanboard.egg-info/top_level.txt
+kanboard/tests/__init__.py
+kanboard/tests/test_kanboard.py
\ No newline at end of file
diff --git a/kanboard.egg-info/dependency_links.txt b/kanboard.egg-info/dependency_links.txt
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/kanboard.egg-info/dependency_links.txt
@@ -0,0 +1 @@
+
diff --git a/kanboard.egg-info/not-zip-safe b/kanboard.egg-info/not-zip-safe
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/kanboard.egg-info/not-zip-safe
@@ -0,0 +1 @@
+
diff --git a/kanboard.egg-info/pbr.json b/kanboard.egg-info/pbr.json
new file mode 100644
index 0000000..6bd1d67
--- /dev/null
+++ b/kanboard.egg-info/pbr.json
@@ -0,0 +1 @@
+{"git_version": "131eef3", "is_release": true}
\ No newline at end of file
diff --git a/kanboard.egg-info/requires.txt b/kanboard.egg-info/requires.txt
new file mode 100644
index 0000000..e49138f
--- /dev/null
+++ b/kanboard.egg-info/requires.txt
@@ -0,0 +1,2 @@
+pbr>=1.8
+setuptools>=16.0,!=24.0.0
diff --git a/kanboard.egg-info/top_level.txt b/kanboard.egg-info/top_level.txt
new file mode 100644
index 0000000..340c9f8
--- /dev/null
+++ b/kanboard.egg-info/top_level.txt
@@ -0,0 +1 @@
+kanboard
diff --git a/kanboard/__init__.py b/kanboard/__init__.py
new file mode 100644
index 0000000..4ba8b59
--- /dev/null
+++ b/kanboard/__init__.py
@@ -0,0 +1 @@
+from .client import Kanboard
diff --git a/kanboard/client.py b/kanboard/client.py
new file mode 100644
index 0000000..4b24af9
--- /dev/null
+++ b/kanboard/client.py
@@ -0,0 +1,106 @@
+import json
+import base64
+
+from kanboard import exceptions
+
+try:
+ from urllib import request as http
+except ImportError:
+ import urllib2 as http
+
+
+class Kanboard(object):
+ """
+ Kanboard API client
+
+ Example:
+
+ from kanboard import Kanboard
+
+ kb = Kanboard(url="http://localhost/jsonrpc.php",
+ username="jsonrpc",
+ password="your_api_token")
+
+ project_id = kb.create_project(name="My project")
+
+ """
+
+ def __init__(self, url, username, password, auth_header='Authorization'):
+ """
+ Constructor
+
+ Args:
+ url: API url endpoint
+ username: API username or real username
+ password: API token or user password
+ auth_header: API HTTP header
+
+ """
+ self._url = url
+ self._username = username
+ self._password = password
+ self._auth_header = auth_header
+
+ def __getattr__(self, name):
+ def function(*args, **kwargs):
+ return self.execute(method=self._to_camel_case(name), **kwargs)
+ return function
+
+ @staticmethod
+ def _to_camel_case(snake_str):
+ components = snake_str.split('_')
+ return components[0] + ''.join(x.title() for x in components[1:])
+
+ @staticmethod
+ def _parse_response(response):
+ try:
+ body = json.loads(response.decode())
+
+ if 'error' in body:
+ message = body.get('error').get('message')
+ raise exceptions.KanboardClientException(message)
+
+ return body.get('result')
+ except ValueError:
+ return None
+
+ def _do_request(self, headers, body):
+ try:
+ request = http.Request(self._url,
+ headers=headers,
+ data=json.dumps(body).encode())
+
+ response = http.urlopen(request).read()
+ except Exception as e:
+ raise exceptions.KanboardClientException(str(e))
+ return self._parse_response(response)
+
+ def execute(self, method, **kwargs):
+ """
+ Call remote API procedure
+
+ Args:
+ method: Procedure name
+ kwargs: Procedure named arguments
+
+ Returns:
+ Procedure result
+
+ Raises:
+ urllib2.HTTPError: Any HTTP error (Python 2)
+ urllib.error.HTTPError: Any HTTP error (Python 3)
+ """
+ payload = {
+ 'id': 1,
+ 'jsonrpc': '2.0',
+ 'method': method,
+ 'params': kwargs
+ }
+
+ credentials = base64.b64encode('{}:{}'.format(self._username, self._password).encode())
+ headers = {
+ self._auth_header: 'Basic {}'.format(credentials.decode()),
+ 'Content-Type': 'application/json',
+ }
+
+ return self._do_request(headers, payload)
diff --git a/kanboard/exceptions.py b/kanboard/exceptions.py
new file mode 100644
index 0000000..3943a3b
--- /dev/null
+++ b/kanboard/exceptions.py
@@ -0,0 +1,2 @@
+class KanboardClientException(Exception):
+ pass
diff --git a/kanboard/tests/__init__.py b/kanboard/tests/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/kanboard/tests/test_kanboard.py b/kanboard/tests/test_kanboard.py
new file mode 100644
index 0000000..aee08b9
--- /dev/null
+++ b/kanboard/tests/test_kanboard.py
@@ -0,0 +1,45 @@
+import mock
+import sys
+import unittest
+
+from kanboard import client
+from kanboard import exceptions
+
+
+class TestKanboard(unittest.TestCase):
+
+ def setUp(self):
+ self.url = 'some api url'
+ self.client = client.Kanboard(self.url, 'username', 'password')
+ self.request, self.urlopen = self._create_mocks()
+
+ def test_api_call(self):
+ body = b'{"jsonrpc": "2.0", "result": true, "id": 123}'
+ self.urlopen.return_value.read.return_value = body
+ self.assertEquals(True, self.client.remote_procedure())
+ self.request.assert_called_once_with(self.url,
+ data=mock.ANY,
+ headers=mock.ANY)
+
+ def test_http_error(self):
+ self.urlopen.side_effect = Exception()
+ with self.assertRaises(exceptions.KanboardClientException):
+ self.client.remote_procedure()
+
+ def test_application_error(self):
+ body = b'{"jsonrpc": "2.0", "error": {"code": -32603, "message": "Internal error"}, "id": 123}'
+ self.urlopen.return_value.read.return_value = body
+
+ with self.assertRaises(exceptions.KanboardClientException, msg='Internal error'):
+ self.client.remote_procedure()
+
+ @staticmethod
+ def _create_mocks():
+ if sys.version_info[0] < 3:
+ urlopen_patcher = mock.patch('urllib2.urlopen')
+ request_patcher = mock.patch('urllib2.Request')
+ else:
+ request_patcher = mock.patch('urllib.request.Request')
+ urlopen_patcher = mock.patch('urllib.request.urlopen')
+
+ return request_patcher.start(), urlopen_patcher.start()
diff --git a/requirements.txt b/requirements.txt
new file mode 100644
index 0000000..dc314a4
--- /dev/null
+++ b/requirements.txt
@@ -0,0 +1,2 @@
+pbr>=1.8 # Apache-2.0
+setuptools>=16.0,!=24.0.0 # PSF/ZPL
\ No newline at end of file
diff --git a/setup.cfg b/setup.cfg
new file mode 100644
index 0000000..61709a0
--- /dev/null
+++ b/setup.cfg
@@ -0,0 +1,29 @@
+[metadata]
+name = kanboard
+author = Frédéric Guillot
+author-email = fred at kanboard.net
+summary = Kanboard API client
+description-file = README.rst
+home-page = https://github.com/kanboard/kanboard-api-python
+license = MIT
+classifier =
+ Intended Audience :: Developers
+ Intended Audience :: Information Technology
+ License :: OSI Approved :: MIT License
+ Operating System :: OS Independent
+ Programming Language :: Python
+ Programming Language :: Python :: 2
+ Programming Language :: Python :: 3
+keywords =
+ kanboard
+ api
+
+[files]
+packages =
+ kanboard
+
+[egg_info]
+tag_build =
+tag_date = 0
+tag_svn_revision = 0
+
diff --git a/setup.py b/setup.py
new file mode 100644
index 0000000..ce14d42
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,8 @@
+#!/usr/bin/env python
+
+from setuptools import setup
+
+setup(
+ setup_requires=['pbr>=1.9', 'setuptools>=17.1'],
+ pbr=True,
+)
diff --git a/test-requirements.txt b/test-requirements.txt
new file mode 100644
index 0000000..d34cc49
--- /dev/null
+++ b/test-requirements.txt
@@ -0,0 +1,4 @@
+flake8>=2.5.4,<2.6.0 # MIT
+mock>=2.0 # BSD
+nose # LGPL
+pep8==1.5.7 # MIT
\ No newline at end of file
diff --git a/tox.ini b/tox.ini
new file mode 100644
index 0000000..3fbdd08
--- /dev/null
+++ b/tox.ini
@@ -0,0 +1,21 @@
+[tox]
+envlist = py27,py34,py35,pep8
+
+[testenv]
+deps =
+ -r{toxinidir}/requirements.txt
+ -r{toxinidir}/test-requirements.txt
+commands = nosetests --tests kanboard.tests
+
+[testenv:venv]
+commands = {posargs}
+
+[testenv:pep8]
+commands =
+ flake8 {posargs}
+
+[flake8]
+ignore = E125,E123,E129
+show-source = True
+max-line-length = 120
+exclude = .git,.venv,.tox,build,dist,*egg,kanboard/__init__.py
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-kanboard.git
More information about the Python-modules-commits
mailing list