Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/msiedlarek/wiring
Architectural foundation for Python applications.
https://github.com/msiedlarek/wiring
Last synced: 21 days ago
JSON representation
Architectural foundation for Python applications.
- Host: GitHub
- URL: https://github.com/msiedlarek/wiring
- Owner: msiedlarek
- License: apache-2.0
- Archived: true
- Created: 2014-09-06T11:58:50.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2016-10-30T13:23:20.000Z (about 8 years ago)
- Last Synced: 2024-07-31T09:11:48.059Z (4 months ago)
- Language: Python
- Homepage: http://wiring.readthedocs.org
- Size: 127 KB
- Stars: 26
- Watchers: 5
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
- awesome-dependency-injection-in-python - Wiring - Architectural foundation for Python applications. [🐍, Apache License 2.0]. (Software / Archived or unmaintained DI frameworks)
README
Wiring
******.. image:: http://img.shields.io/pypi/v/wiring.svg?style=flat
:target: https://pypi.python.org/pypi/wiring/
.. image:: http://img.shields.io/pypi/l/wiring.svg?style=flat
:target: https://pypi.python.org/pypi/wiring/
.. image:: http://img.shields.io/travis/msiedlarek/wiring.svg?style=flat
:target: https://travis-ci.org/msiedlarek/wiring
.. image:: http://img.shields.io/coveralls/msiedlarek/wiring.svg?style=flat
:target: https://coveralls.io/r/msiedlarek/wiring
.. image:: https://readthedocs.org/projects/wiring/badge/?style=flat
:target: http://wiring.readthedocs.org**Wiring provides architectural foundation for Python applications**,
featuring:* dependency injection
* interface definition and validation
* modular component configuration
* small, extremely pedantic codebaseWiring is supported and tested on Python 2.7, Python 3.4, Python 3.5, PyPy and
PyPy 3.Quick Peek
==========.. code-block:: python
import wiring
from wiring import provides, scope, inject, injected, implementsclass DatabaseModule(wiring.Module):
@provides('db_connection')
@scope(wiring.ThreadScope)
def provide_db_connection(self, database_url=injected('database_url')):
return db_engine.connect(database_url)class IUserManager(wiring.Interface):
def get(id):
"""Get user by ID."""@implements(IUserManager)
class DefaultUserManager(object):@inject('db_connection')
def __init__(self, db_connection):
self.db = db_connectiondef get(self, id):
return self.db.sql('SELECT * FROM users WHERE id = :id', id=id)class UserModule(wiring.Module):
factories = {
IUserManager: DefaultUserManager,
}graph = wiring.Graph()
DatabaseModule().add_to(graph)
UserModule().add_to(graph)
graph.register_instance('database_url', 'sqlite://some.db')
graph.validate()user_manager = graph.get(IUserManager)
user = user_manager.get(12)Documentation
=============Full documentation is available at `wiring.readthedocs.org
`_.Support
=======Support is provided on a best-effort basis, through `Stack Overflow
`_. Please tag your question *wiring*.For commercial support, please contact me directly at [email protected].
Development
===========You can install package for development and testing with::
virtualenv environment
. environment/bin/activate
pip install sphinx tox flake8 wheel sphinx_rtd_theme
pip install -e .To run the test suite on supported Python versions use::
tox
Or on a single version::
tox -e py27
To validate PEP8 compliance and run code static checking::
tox -e flake8
To generate test coverage report::
rm -rf .coverage coverage
tox -- --with-coverage
open coverage/index.htmlTo generate html documentation::
cd docs
make html
open _build/html/index.htmlTo release::
git tag -s -u [email protected] v0.4.0
python setup.py register
python setup.py sdist upload -s -i [email protected]
python setup.py bdist_wheel upload -s -i [email protected]
git push origin v0.4.0License
=======Copyright 2014-2015 Mikołaj Siedlarek
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this software except in compliance with the License.
You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.