You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
2.1 KiB

4 years ago
  1. Metadata-Version: 2.1
  2. Name: backcall
  3. Version: 0.1.0
  4. Summary: Specifications for callback functions passed in to an API
  5. Home-page: https://github.com/takluyver/backcall
  6. Author: Thomas Kluyver
  7. Author-email: takowl@gmail.com
  8. License: BSD
  9. Platform: UNKNOWN
  10. Classifier: Development Status :: 2 - Pre-Alpha
  11. Classifier: Intended Audience :: Developers
  12. Classifier: License :: OSI Approved :: BSD License
  13. Classifier: Natural Language :: English
  14. Classifier: Programming Language :: Python :: 2
  15. Classifier: Programming Language :: Python :: 2.7
  16. Classifier: Programming Language :: Python :: 3
  17. Classifier: Programming Language :: Python :: 3.3
  18. ========
  19. backcall
  20. ========
  21. .. image:: https://travis-ci.org/takluyver/backcall.png?branch=master
  22. :target: https://travis-ci.org/takluyver/backcall
  23. Specifications for callback functions passed in to an API
  24. If your code lets other people supply callback functions, it's important to
  25. specify the function signature you expect, and check that functions support that.
  26. Adding extra parameters later would break other peoples code unless you're careful.
  27. backcall provides a way of specifying the callback signature using a prototype
  28. function::
  29. from backcall import callback_prototype
  30. @callback_prototype
  31. def handle_ping(sender, delay=None):
  32. # Specify positional parameters without a default, and keyword
  33. # parameters with a default.
  34. pass
  35. def register_ping_handler(callback):
  36. # This checks and adapts the function passed in:
  37. callback = handle_ping.adapt(callback)
  38. ping_callbacks.append(callback)
  39. If the callback takes fewer parameters than your prototype, *backcall* will wrap
  40. it in a function that discards the extra arguments. If the callback expects
  41. more arguments, a TypeError is thrown when it is registered.
  42. For more details, see the `docs <http://backcall.readthedocs.org/en/latest/>`_ or
  43. the `Demo notebook <http://nbviewer.ipython.org/github/takluyver/backcall/blob/master/Demo.ipynb>`_.
  44. The tests are run with `pytest <http://pytest.org/latest/>`_. In the root directory,
  45. execute::
  46. py.test