Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/unistra/britney-utils
Utilities for Britney, a SPORE client written in Python
https://github.com/unistra/britney-utils
Last synced: 10 days ago
JSON representation
Utilities for Britney, a SPORE client written in Python
- Host: GitHub
- URL: https://github.com/unistra/britney-utils
- Owner: unistra
- License: gpl-2.0
- Created: 2013-11-20T13:13:07.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2015-04-08T10:22:26.000Z (over 9 years ago)
- Last Synced: 2024-10-21T15:51:22.861Z (27 days ago)
- Language: Python
- Homepage:
- Size: 156 KB
- Stars: 1
- Watchers: 21
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
=============
britney-utils
=============Britney-utils comes with some utilities to create and manage clients build by Britney.
.. image:: https://secure.travis-ci.org/unistra/britney-utils.png?branch=master
:target: https://travis-ci.org/unistra/britney-utils
.. image:: https://coveralls.io/repos/unistra/britney-utils/badge.png
:target: https://coveralls.io/r/unistra/britney-utils.. image:: https://landscape.io/github/unistra/britney-utils/master/landscape.svg?style=flat
:target: https://landscape.io/github/unistra/britney-utils/master
:alt: Code HealthInstall
=======britney-utils is working on Python 2.7 and Python >= 3.2. To install the module, use pip ::
$> pip install britney-utils
Use it...
=========... to create a basic client
----------------------------You can easily create a client with the **get_client** function. It will create and save the client to retrieve it later with his name, acting as a cache ::
import britney_utils
client = britney_utils.get_client('my_client',
'/path/to/spore/description.json',
base_url='http://my-rest-api.org/v1/')... to reset an instance
------------------------If an instance is already created with a name you gave in first place, you can easily reset and rebuild it. In this example, we except that the **my_client** SPORE client already exist ::
client = britney_utils.get_client('my_client',
'/path/to/spore/description.json',
reset=True)A new instance is created with the **my_client** name and saved
... to create a pre-build instance with middlewares
---------------------------------------------------Creating a rich client with all middlewares needed activated is useful. You can do this like this ::
from britney.middleware import auth, format
import britney_utilsmiddlewares = (
(format.Json, {'predicate': lambda env: env['format'] == 'json'}),
(auth.Basic, {'username': 'toto', 'password': 'xxxxxx'})
)client = britney_utils.get_client('my_client',
'/path/to/spore/description.json',
middlewares=middlewares)