{ "info": { "author": "Tavish Armstrong", "author_email": "tavisharmstrong@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 2 - Pre-Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Natural Language :: English", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7" ], "description": "===============================\n pyadbc\n ===============================\n \n .. image:: https://badge.fury.io/py/pyadbc.png\n :target: http://badge.fury.io/py/pyadbc\n \n .. image:: https://travis-ci.org/tarmstrong/pyadbc.png?branch=master\n :target: https://travis-ci.org/tarmstrong/pyadbc\n \n .. image:: https://pypip.in/d/pyadbc/badge.png\n :target: https://crate.io/packages/pyadbc?version=latest\n \n \n PyADBC: Design by Contract in Python\n \n \n PyADBC provides pure python support for `Design by\n Contract `__.\n Invariants, pre- and post-conditions are added using decorators.\n \n * Free software: BSD license\n \n Usage\n -----\n \n Invariants\n ~~~~~~~~~~\n \n To define an invariant on a class (a condition that always holds after\n the object is instantiated), use the ``@invariant`` decorator. The\n ``self`` passed into the passed lambda is the same ``self`` that would\n be passed to a method.\n \n ::\n \n @invariant(lambda self: self.capacity >= 0)\n class List(object):\n # ...\n \n Preconditions\n ~~~~~~~~~~~~~\n \n Preconditions can be specified with ``@requires``. These are properties\n that must evaluate to ``True`` *before* the method is run.\n \n ::\n \n @requires(lambda self: self.size() < self.capacity)\n def append(self, bla):\n self._size += 1\n self.things.append(bla)\n \n Postconditions\n ~~~~~~~~~~~~~~\n \n Postconditions can be specified with ``@ensures``:\n \n ::\n \n @ensures(lambda self: self.size() == len(self.things))\n def append(self, bla):\n self._size += 1\n self.things.append(bla)\n \n These are properties that must evaluate to ``True`` *after* the method\n has run.\n \n ``@old`` for before/after comparisons\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n \n In order to compare properties of the object before and after an\n operation, PyADBC provides the ``@old`` decorator. You can use it to\n \"cache\" values for use in the postcondition.\n \n For example, the following method's postcondition guarantees that the\n ``x`` instance attribute is increased by one. Dictionaries returned in\n the functions passed to ``@old`` will be merged and passed as a second\n argument to the postcondition functions.\n \n ::\n \n @ensures(lambda self, old: old['x'] + 1 == self.x,\n lambda self, old: old['size'] < 0)\n @old(lambda self: {'x': self.x, 'size': self._size})\n def doThing(self):\n self.x -= 1\n \n Exceptions\n ~~~~~~~~~~\n \n If any conditions defined by the above decorators evaluate to ``False``,\n one of the following exceptions will be raised based on what kind of\n condition it is:\n \n - ``PreconditionFailedException``, which implies that the client of the\n class failed to satisfy the class's contract.\n - ``PostconditionFailedException``, which implies that the object\n itself failed to satisfy its class's contract.\n - ``InvariantFailedException``, which implies that the object has\n entered an illegal state.\n \n ``@dbcinherit`` for inheriting classes\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n \n An important feature of DBC is that it can validate the `Liskov\n Substitution\n Principle `__.\n That is, if a child class ``CoolList`` inherits from the base class\n ``List``, its operations should satsify ``List``'s contracts. This gives\n some assurance that the principle holds for the child class.\n \n To do this with PyADBC, you need to explicitly decorate the child class,\n e.g.:\n \n ::\n \n @dbcinherit\n class CoolList(List):\n # ...\n \n If ``CoolList`` overrides the ``append()`` method, the contract of\n ``List``'s ``append()`` method will be applied to ``CoolList``'s\n ``append()``.\n \n This also currently works with multiple inheritance.\n \n Other solutions\n ---------------\n \n - `PyDBC `__, which uses a metaclass.\n - `pycontract `__, which uses\n docstrings. See the Python Enhancement Proposal (PEP) that references\n this implementation\n `here `__.\n \n Contributing\n ------------\n \n See ``TODO.md`` for missing features. Suggestions and bug reports are\n always welcome.\n \n Acknowledgements\n ----------------\n \n Thanks to\n \n - Prof. Constantinos Constantinides, for his feedback regarding Liskov\n and for teaching me about DBC in the first place\n \n \n \n \n \n History\n -------\n \n 0.1.0 (2013-08-11)\n ++++++++++++++++++\n \n * First release on PyPI.", "description_content_type": null, "docs_url": null, "download_url": null, "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/tarmstrong/pyadbc", "keywords": "pyadbc", "license": "BSD", "maintainer": null, "maintainer_email": null, "name": "pyadbc", "package_url": "https://pypi.org/project/pyadbc/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/pyadbc/", "project_urls": { "Homepage": "https://github.com/tarmstrong/pyadbc" }, "release_url": "https://pypi.org/project/pyadbc/0.1.0/", "requires_dist": null, "requires_python": null, "summary": "PyADBC: Design by Contract in Python", "version": "0.1.0" }, "last_serial": 868006, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "10a190445eae52b68dcac78d2b9a9c88", "sha256": "c9854b74f3fbdd17b08a35a5cf7ab56bac42b34e33368bfed9caaebd128502b9" }, "downloads": -1, "filename": "pyadbc-0.1.0.tar.gz", "has_sig": false, "md5_digest": "10a190445eae52b68dcac78d2b9a9c88", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7771, "upload_time": "2013-09-17T16:39:59", "url": "https://files.pythonhosted.org/packages/3a/1b/29a448fa9aa1d8d16b0fab11680e482e4c745c9a4434e9b4de4f0f7fb305/pyadbc-0.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "10a190445eae52b68dcac78d2b9a9c88", "sha256": "c9854b74f3fbdd17b08a35a5cf7ab56bac42b34e33368bfed9caaebd128502b9" }, "downloads": -1, "filename": "pyadbc-0.1.0.tar.gz", "has_sig": false, "md5_digest": "10a190445eae52b68dcac78d2b9a9c88", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7771, "upload_time": "2013-09-17T16:39:59", "url": "https://files.pythonhosted.org/packages/3a/1b/29a448fa9aa1d8d16b0fab11680e482e4c745c9a4434e9b4de4f0f7fb305/pyadbc-0.1.0.tar.gz" } ] }