Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revamp the entire library for 4.0.0.
- Loading branch information
Showing
81 changed files
with
9,827 additions
and
6,029 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,22 @@ | ||
language: python | ||
sudo: false | ||
language: python | ||
python: | ||
- 2.7 | ||
- 3.4 | ||
- 3.5 | ||
- 3.6 | ||
- 3.7 | ||
services: | ||
- docker | ||
before_install: | ||
- sh scripts/setup_arangodb_travis.sh | ||
- docker run --name arango -d -p 8529:8529 -e ARANGO_ROOT_PASSWORD=passwd arangodb/arangodb:3.3.8 | ||
- docker cp tests/static/service.zip arango:/tmp/service.zip | ||
install: | ||
- pip install coverage | ||
- pip install pytest | ||
- pip install pytest-cov | ||
- pip install python-coveralls | ||
- python setup.py install | ||
- pip install flake8 mock pytest pytest-cov python-coveralls sphinx | ||
- pip install . | ||
script: | ||
- if [[ $TRAVIS_PYTHON_VERSION == 2.7 || $TRAVIS_PYTHON_VERSION == 3.4 ]]; | ||
then py.test --cov=arango --ignore=tests/test_asyncio.py; | ||
else py.test --cov=arango; | ||
fi | ||
- python -m flake8 | ||
- python -m sphinx -b doctest docs build | ||
- py.test --complete -s -v --cov=arango | ||
after_success: | ||
- coveralls | ||
- pkill -9 -f arango |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include README.rst LICENSE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
from arango.client import ArangoClient | ||
from arango.client import ArangoClient # noqa: F401 | ||
from arango.exceptions import * # noqa: F401 F403 | ||
from arango.http import * # noqa: F401 F403 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,60 @@ | ||
from __future__ import absolute_import, unicode_literals | ||
|
||
__all__ = ['APIWrapper'] | ||
|
||
|
||
class APIWrapper(object): | ||
"""API wrapper which facilitates access to the executor. | ||
"""API wrapper base class. | ||
This is a utility class which wraps the API executor. | ||
:param connection: HTTP connection. | ||
:type connection: arango.connection.Connection | ||
:param executor: API executor. | ||
:type executor: arango.api.APIExecutor | ||
:type executor: arango.executor.DefaultExecutor | ||
""" | ||
|
||
def __init__(self, connection, executor): | ||
self._conn = connection | ||
self._executor = executor | ||
self._context = { | ||
'APIExecutor': 'default', | ||
'AsyncExecutor': 'async', | ||
'BatchExecutor': 'batch', | ||
'TransactionExecutor': 'transaction', | ||
}[self._executor.__class__.__name__] | ||
self._is_transaction = self.context == 'transaction' | ||
|
||
@property | ||
def context(self): | ||
"""Return the API execution context (e.g. "async", "batch"). | ||
def db_name(self): | ||
"""Return the database name. | ||
:return: API execution context. | ||
:rtype: str or unicode | ||
:return: Database name. | ||
""" | ||
return self._context | ||
return self._conn.db_name | ||
|
||
def _execute(self, request, response_handler): | ||
"""Execute an API call. | ||
@property | ||
def username(self): | ||
"""Return the username. | ||
:param request: HTTP request. | ||
:type request: arango.request.Request | ||
:param response_handler: HTTP response handler. | ||
:type response_handler: callable | ||
:return: API execution result. | ||
:rtype: dict or list or int or bool or str or unicode | ||
:returns: Username. | ||
:rtype: str | unicode | ||
""" | ||
return self._executor.execute(self._conn, request, response_handler) | ||
|
||
return self._conn.username | ||
|
||
class APIExecutor(object): | ||
"""Base API executor. | ||
@property | ||
def context(self): | ||
"""Return the API execution context. | ||
API executor dictates how an API request is executed depending on the | ||
context (e.g. async, batch). See :class:`arango.async.AsyncExecutor` | ||
or :class:`arango.batch.BatchExecutor` for more examples. | ||
""" | ||
Possible values are "default", "async", "batch" and "transaction". | ||
def execute(self, connection, request, response_handler): | ||
"""Execute an API request. | ||
:return: API execution context. | ||
:rtype: str | unicode | ||
""" | ||
return self._executor.context | ||
|
||
This method is meant to be overridden by subclasses and its behaviour | ||
re-defined depending on the execution context (e.g. async, batch). For | ||
more concrete examples, see :class:`arango.async.AsyncExecutor` or | ||
:class:`arango.batch.BatchExecutor`. | ||
def _execute(self, request, response_handler): | ||
"""Execute an API according to the execution context. | ||
:param connection: HTTP connection. | ||
:type connection: arango.connection.Connection | ||
:param request: HTTP request. | ||
:type request: arango.request.Request | ||
:param response_handler: HTTP response handler. | ||
:type response_handler: callable | ||
:return: API call result or its future. | ||
:rtype: bool or list or dict or arango.connection.Future | ||
:return: API execution result. | ||
:rtype: str | unicode | bool | int | list | dict | ||
""" | ||
response = connection.send_request(request) | ||
return response_handler(response) | ||
return self._executor.execute(request, response_handler) |
Oops, something went wrong.