{ "info": { "author": "Syrus Akbary", "author_email": "me@syrusakbary.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Software Development :: Libraries" ], "description": "Promise\n=======\n\nThis is a implementation of Promises in Python. It is a super set of\nPromises/A+ designed to have readable, performant code and to provide\njust the extensions that are absolutely necessary for using promises in\nPython.\n\nIts fully compatible with the `Promises/A+\nspec `__\n\n|travis| |pypi| |coveralls|\n\nInstallation\n------------\n\n::\n\n $ pip install pypromise\n\nUsage\n-----\n\nThe example below shows how you can load the promise library. It then\ndemonstrates creating a promise from scratch. You simply call\n``Promise(fn)``. There is a complete specification for what is returned\nby this method in\n`Promises/A+ `__.\n\n.. code:: python\n\n from promise import Promise\n\n promise = Promise(\n lambda resolve, reject: resolve('RESOLVED!')\n )\n\nAPI\n---\n\nBefore all examples, you will need:\n\n.. code:: python\n\n from promise import Promise\n\nPromise(resolver)\n~~~~~~~~~~~~~~~~~\n\nThis creates and returns a new promise. ``resolver`` must be a function.\nThe ``resolver`` function is passed two arguments:\n\n1. ``resolve`` should be called with a single argument. If it is called\n with a non-promise value then the promise is fulfilled with that\n value. If it is called with a promise (A) then the returned promise\n takes on the state of that new promise (A).\n2. ``reject`` should be called with a single argument. The returned\n promise will be rejected with that argument.\n\nStatic Functions\n~~~~~~~~~~~~~~~~\n\nThese methods are invoked by calling ``Promise.methodName``.\n\nPromise.resolve(value)\n^^^^^^^^^^^^^^^^^^^^^^\n\nConverts values and foreign promises into Promises/A+ promises. If you\npass it a value then it returns a Promise for that value. If you pass it\nsomething that is close to a promise (such as a jQuery attempt at a\npromise) it returns a Promise that takes on the state of ``value``\n(rejected or fulfilled).\n\nPromise.reject(value)\n^^^^^^^^^^^^^^^^^^^^^\n\nReturns a rejected promise with the given value.\n\nPromise.all(list)\n^^^^^^^^^^^^^^^^^\n\nReturns a promise for a list. If it is called with a single argument\nthen this returns a promise for a copy of that list with any promises\nreplaced by their fulfilled values. e.g.\n\n.. code:: python\n\n p = Promise.all([Promise.resolve('a'), 'b', Promise.resolve('c')]) \\\n .then(lambda res: res == ['a', 'b', 'c'])\n\n assert p.value is True\n\nInstance Methods\n~~~~~~~~~~~~~~~~\n\nThese methods are invoked on a promise instance by calling\n``myPromise.methodName``\n\npromise.then(on\\_fulfilled, on\\_rejected)\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nThis method follows the `Promises/A+\nspec `__. It explains\nthings very clearly so I recommend you read it.\n\nEither ``on_fulfilled`` or ``on_rejected`` will be called and they will\nnot be called more than once. They will be passed a single argument and\nwill always be called asynchronously (in the next turn of the event\nloop).\n\nIf the promise is fulfilled then ``on_fulfilled`` is called. If the\npromise is rejected then ``on_rejected`` is called.\n\nThe call to ``.then`` also returns a promise. If the handler that is\ncalled returns a promise, the promise returned by ``.then`` takes on the\nstate of that returned promise. If the handler that is called returns a\nvalue that is not a promise, the promise returned by ``.then`` will be\nfulfilled with that value. If the handler that is called throws an\nexception then the promise returned by ``.then`` is rejected with that\nexception.\n\npromise.catch(on\\_rejected)\n^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nSugar for ``promise.then(None, on_rejected)``, to mirror ``catch`` in\nsynchronous code.\n\npromise.done(on\\_fulfilled, on\\_rejected)\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nThe same semantics as ``.then`` except that it does not return a promise\nand any exceptions are re-thrown so that they can be logged (crashing\nthe application in non-browser environments)\n\nOther package functions\n-----------------------\n\nis\\_thenable(obj)\n~~~~~~~~~~~~~~~~~\n\nThis function checks if the ``obj`` is a ``Promise``, or could be\n``promisify``\\ ed.\n\npromisify(obj)\n~~~~~~~~~~~~~~\n\nThis function wraps the ``obj`` act as a ``Promise`` if possible. Python\n``Future``\\ s are supported, with a callback to ``promise.done`` when\nresolved.\n\nNotes\n=====\n\nThis package is heavily insipired in\n`aplus `__.\n\nLicense\n-------\n\n`MIT\nLicense `__\n\n.. |travis| image:: https://img.shields.io/travis/syrusakbary/pypromise.svg?style=flat\n :target: https://travis-ci.org/syrusakbary/pypromise\n.. |pypi| image:: https://img.shields.io/pypi/v/pypromise.svg?style=flat\n :target: https://pypi.python.org/pypi/pypromise\n.. |coveralls| image:: https://coveralls.io/repos/syrusakbary/pypromise/badge.svg?branch=master&service=github\n :target: https://coveralls.io/github/syrusakbary/pypromise?branch=master", "description_content_type": null, "docs_url": null, "download_url": "https://github.com/syrusakbary/promise/releases", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/syrusakbary/promise", "keywords": "concurrent future deferred promise", "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "pypromise", "package_url": "https://pypi.org/project/pypromise/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/pypromise/", "project_urls": { "Download": "https://github.com/syrusakbary/promise/releases", "Homepage": "https://github.com/syrusakbary/promise" }, "release_url": "https://pypi.org/project/pypromise/0.4/", "requires_dist": null, "requires_python": null, "summary": "Promises/A+ implementation for Python", "version": "0.4" }, "last_serial": 2098170, "releases": { "0.0.1": [], "0.3": [ { "comment_text": "", "digests": { "md5": "696302b7896946b2e90a1db9f52d5f53", "sha256": "be89540b85ac7392a1ec3d9a8bbdaa1999672d7e4d54b052e16093543ac372b9" }, "downloads": -1, "filename": "pypromise-0.3.tar.gz", "has_sig": false, "md5_digest": "696302b7896946b2e90a1db9f52d5f53", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3435, "upload_time": "2016-05-03T07:44:55", "url": "https://files.pythonhosted.org/packages/ca/4b/c9f86302e7153e87781035c3ec5a2b6efecd580f03f332e7419868265c1a/pypromise-0.3.tar.gz" } ], "0.4": [ { "comment_text": "", "digests": { "md5": "14991ab65536764130a1239db5172a08", "sha256": "54ef0ccde1e0dab3478cd2cc7211213f1c360eda0de39c0ee4321d4d12deffb1" }, "downloads": -1, "filename": "pypromise-0.4.tar.gz", "has_sig": false, "md5_digest": "14991ab65536764130a1239db5172a08", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6795, "upload_time": "2016-05-04T04:06:24", "url": "https://files.pythonhosted.org/packages/60/0c/051e825255eb642a1f92688c9956a7a93f1d6d29ee4042c7828c3df946f9/pypromise-0.4.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "14991ab65536764130a1239db5172a08", "sha256": "54ef0ccde1e0dab3478cd2cc7211213f1c360eda0de39c0ee4321d4d12deffb1" }, "downloads": -1, "filename": "pypromise-0.4.tar.gz", "has_sig": false, "md5_digest": "14991ab65536764130a1239db5172a08", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6795, "upload_time": "2016-05-04T04:06:24", "url": "https://files.pythonhosted.org/packages/60/0c/051e825255eb642a1f92688c9956a7a93f1d6d29ee4042c7828c3df946f9/pypromise-0.4.tar.gz" } ] }