[Python-modules-commits] [obsub] 01/02: New upstream version 0.2

Free Ekanayaka freee at moszumanska.debian.org
Tue Nov 15 18:14:33 UTC 2016


This is an automated email from the git hooks/post-receive script.

freee pushed a commit to branch master
in repository obsub.

commit 7685cbb709f38156ba0c42d226eede3346371b6c
Author: Free Ekanayaka <freee at debian.org>
Date:   Tue Nov 15 17:55:02 2016 +0000

    New upstream version 0.2
---
 CHANGELOG.rst                       |  42 +++++++
 LICENSE.rst                         | 140 +++++++++++++++++++++++
 MANIFEST.in                         |   3 +
 PKG-INFO                            | 203 +++++++++++++++++++++++++++++++++
 README.rst                          | 144 +++++++++++++++++++++++
 obsub.egg-info/PKG-INFO             | 203 +++++++++++++++++++++++++++++++++
 obsub.egg-info/SOURCES.txt          |  15 +++
 obsub.egg-info/dependency_links.txt |   1 +
 obsub.egg-info/top_level.txt        |   1 +
 obsub.py                            | 222 ++++++++++++++++++++++++++++++++++++
 setup.cfg                           |  10 ++
 setup.py                            |  38 ++++++
 test/py3/test_signature.py          |  37 ++++++
 test/test_core.py                   | 134 ++++++++++++++++++++++
 test/test_signature.py              |  12 ++
 test/test_weakref.py                |  86 ++++++++++++++
 16 files changed, 1291 insertions(+)

diff --git a/CHANGELOG.rst b/CHANGELOG.rst
new file mode 100644
index 0000000..8f5994e
--- /dev/null
+++ b/CHANGELOG.rst
@@ -0,0 +1,42 @@
+Changelog
+---------
+
+v0.2
+~~~~
+
+From a user perspective the preservation of function signatures and a couple of
+bug fixes are probably most relevant. Python 2.5 is no longer tested by
+continuous integration, though we try to avoid unnecessary changes that might
+break backwards compatibility.
+
+In addition, there are quite a number of changes that mostly concern
+developers.
+
+- Function signatures are now preserved correctly by the event decorator. This
+  is true only for python3. On python2 there is no support for default
+  arguments, currently
+- Some fixes to memory handling and tests thereof. This includes a more generic
+  handling of the garbage collection process within the test suite to make it
+  pass on pypy, too.
+- Massive refactoring of test suite from one very long doctest to more focussed
+  unit tests.
+- The documentation has been converted from Markdown to reStructuredText, since
+  it is compatible with both PyPI and GitHub.
+- Various improvements and some streamlining of the documentation.
+- Fix package name in license.
+- Continuous integration now includes coveralls.io support.
+- Support for Python 2.5 is no longer tested using Travis CI, since they have
+  dropped support for this version.
+
+
+v0.1.1
+~~~~~~
+
+- Add __all__ attribute to module
+- Fix a couple of documentation issues
+
+
+v0.1
+~~~~
+
+*Initial release*
diff --git a/LICENSE.rst b/LICENSE.rst
new file mode 100644
index 0000000..2ae3c76
--- /dev/null
+++ b/LICENSE.rst
@@ -0,0 +1,140 @@
+This Python module is licensed under a `CC0
+license <http://creativecommons.org/publicdomain/zero/1.0/>`__.
+
+To the extent possible under law, Eduard Bopp has waived all copyright
+and related or neighboring rights to obsub. This work is published from:
+Germany.
+
+Full license text
+=================
+
+CC0 1.0 Universal
+-----------------
+
+*CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
+LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
+ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS INFORMATION
+ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES REGARDING THE
+USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED HEREUNDER, AND
+DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM THE USE OF THIS DOCUMENT
+OR THE INFORMATION OR WORKS PROVIDED HEREUNDER.*
+
+Statement of Purpose
+~~~~~~~~~~~~~~~~~~~~
+
+The laws of most jurisdictions throughout the world automatically confer
+exclusive Copyright and Related Rights (defined below) upon the creator
+and subsequent owner(s) (each and all, an "owner") of an original work
+of authorship and/or a database (each, a "Work").
+
+Certain owners wish to permanently relinquish those rights to a Work for
+the purpose of contributing to a commons of creative, cultural and
+scientific works ("Commons") that the public can reliably and without
+fear of later claims of infringement build upon, modify, incorporate in
+other works, reuse and redistribute as freely as possible in any form
+whatsoever and for any purposes, including without limitation commercial
+purposes. These owners may contribute to the Commons to promote the
+ideal of a free culture and the further production of creative, cultural
+and scientific works, or to gain reputation or greater distribution for
+their Work in part through the use and efforts of others.
+
+For these and/or other purposes and motivations, and without any
+expectation of additional consideration or compensation, the person
+associating CC0 with a Work (the "Affirmer"), to the extent that he or
+she is an owner of Copyright and Related Rights in the Work, voluntarily
+elects to apply CC0 to the Work and publicly distribute the Work under
+its terms, with knowledge of his or her Copyright and Related Rights in
+the Work and the meaning and intended legal effect of CC0 on those
+rights.
+
+1. Copyright and Related Rights.
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+A Work made available under CC0 may be protected by copyright and
+related or neighboring rights ("Copyright and Related Rights").
+Copyright and Related Rights include, but are not limited to, the
+following:
+
+-  the right to reproduce, adapt, distribute, perform, display,
+   communicate, and translate a Work;
+-  moral rights retained by the original author(s) and/or performer(s);
+-  publicity and privacy rights pertaining to a person's image or
+   likeness depicted in a Work;
+-  rights protecting against unfair competition in regards to a Work,
+   subject to the limitations in paragraph 4(a), below;
+-  rights protecting the extraction, dissemination, use and reuse of
+   data in a Work;
+-  database rights (such as those arising under Directive 96/9/EC of the
+   European Parliament and of the Council of 11 March 1996 on the legal
+   protection of databases, and under any national implementation
+   thereof, including any amended or successor version of such
+   directive); and
+-  other similar, equivalent or corresponding rights throughout the
+   world based on applicable law or treaty, and any national
+   implementations thereof.
+
+2. Waiver.
+~~~~~~~~~~
+
+To the greatest extent permitted by, but not in contravention of,
+applicable law, Affirmer hereby overtly, fully, permanently, irrevocably
+and unconditionally waives, abandons, and surrenders all of Affirmer's
+Copyright and Related Rights and associated claims and causes of action,
+whether now known or unknown (including existing as well as future
+claims and causes of action), in the Work (i) in all territories
+worldwide, (ii) for the maximum duration provided by applicable law or
+treaty (including future time extensions), (iii) in any current or
+future medium and for any number of copies, and (iv) for any purpose
+whatsoever, including without limitation commercial, advertising or
+promotional purposes (the "Waiver"). Affirmer makes the Waiver for the
+benefit of each member of the public at large and to the detriment of
+Affirmer's heirs and successors, fully intending that such Waiver shall
+not be subject to revocation, rescission, cancellation, termination, or
+any other legal or equitable action to disrupt the quiet enjoyment of
+the Work by the public as contemplated by Affirmer's express Statement
+of Purpose.
+
+3. Public License Fallback.
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Should any part of the Waiver for any reason be judged legally invalid
+or ineffective under applicable law, then the Waiver shall be preserved
+to the maximum extent permitted taking into account Affirmer's express
+Statement of Purpose. In addition, to the extent the Waiver is so judged
+Affirmer hereby grants to each affected person a royalty-free, non
+transferable, non sublicensable, non exclusive, irrevocable and
+unconditional license to exercise Affirmer's Copyright and Related
+Rights in the Work (i) in all territories worldwide, (ii) for the
+maximum duration provided by applicable law or treaty (including future
+time extensions), (iii) in any current or future medium and for any
+number of copies, and (iv) for any purpose whatsoever, including without
+limitation commercial, advertising or promotional purposes (the
+"License"). The License shall be deemed effective as of the date CC0 was
+applied by Affirmer to the Work. Should any part of the License for any
+reason be judged legally invalid or ineffective under applicable law,
+such partial invalidity or ineffectiveness shall not invalidate the
+remainder of the License, and in such case Affirmer hereby affirms that
+he or she will not (i) exercise any of his or her remaining Copyright
+and Related Rights in the Work or (ii) assert any associated claims and
+causes of action with respect to the Work, in either case contrary to
+Affirmer's express Statement of Purpose.
+
+4. Limitations and Disclaimers.
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+No trademark or patent rights held by Affirmer are waived, abandoned,
+surrendered, licensed or otherwise affected by this document. Affirmer
+offers the Work as-is and makes no representations or warranties of any
+kind concerning the Work, express, implied, statutory or otherwise,
+including without limitation warranties of title, merchantability,
+fitness for a particular purpose, non infringement, or the absence of
+latent or other defects, accuracy, or the present or absence of errors,
+whether or not discoverable, all to the greatest extent permissible
+under applicable law. Affirmer disclaims responsibility for clearing
+rights of other persons that may apply to the Work or any use thereof,
+including without limitation any person's Copyright and Related Rights
+in the Work. Further, Affirmer disclaims responsibility for obtaining
+any necessary consents, permissions or other rights required for any use
+of the Work. Affirmer understands and acknowledges that Creative Commons
+is not a party to this document and has no duty or obligation with
+respect to this CC0 or use of the Work.
diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644
index 0000000..a913e39
--- /dev/null
+++ b/MANIFEST.in
@@ -0,0 +1,3 @@
+include README.rst CHANGELOG.rst
+include LICENSE.rst
+recursive-include test/py3 *.py
diff --git a/PKG-INFO b/PKG-INFO
new file mode 100644
index 0000000..b8be906
--- /dev/null
+++ b/PKG-INFO
@@ -0,0 +1,203 @@
+Metadata-Version: 1.1
+Name: obsub
+Version: 0.2
+Summary: Implementation of the observer pattern via a decorator
+Home-page: https://github.com/aepsil0n/obsub
+Author: Eduard Bopp
+Author-email: eduard.bopp at aepsil0n.de
+License: Public Domain
+Description: obsub
+        =====
+        
+        |Build Status| |Coverage| |Version| |Downloads| |License|
+        
+        Small python module that implements the observer pattern via a
+        decorator.
+        
+        
+        Description
+        -----------
+        
+        This is based on a `thread on stackoverflow
+        <http://stackoverflow.com/questions/1904351/python-observer-pattern-examples-tips>`_
+        (the example of C#-like events by Jason Orendorff), so I don't take any
+        credit for the idea. I merely made a fancy module with documentation and
+        tests out of it, since I needed it in a bigger project. It is quite
+        handy and I've been using it in a couple of projects, which require some
+        sort of event handling.
+        
+        Thus it is `licensed as
+        CC0 <http://creativecommons.org/publicdomain/zero/1.0/>`__, so basically
+        do-whatever-you-want to the extent legally possible.
+        
+        
+        Installation
+        ------------
+        
+        *obsub* is available on PyPI, so you can simply install it using
+        ``pip install obsub`` or you do it manually using ``setup.py`` as with
+        any python package.
+        
+        
+        Usage
+        -----
+        
+        The ``event`` decorator from the ``obsub`` module is used as follows:
+        
+        .. code:: python
+        
+            from obsub import event
+        
+            # Define a class with an event
+            class Subject(object):
+                @event
+                def on_stuff(self, arg):
+                    print('Stuff {} happens'.format(arg))
+        
+            # Now define an event handler, the observer
+            def handler(subject, arg):
+                print('Stuff {} is handled'.format(arg))
+        
+            # Wire everything up...
+            sub = Subject()
+            sub.on_stuff += handler
+        
+            # And try it!
+            sub.on_stuff('foo')
+        
+        You should now get both print messages from the event itself and the
+        event handler function, like so:
+        
+        ::
+        
+            Stuff foo happens
+            Stuff foo is handled
+        
+        
+        Continuous integration
+        ----------------------
+        
+        For the fun of it, `Travis CI <https://travis-ci.org/aepsil0n/obsub>`__
+        is used for continuous integration. As long as everything is fine, the
+        button below should be green and shiny!
+        
+        |Build Status|
+        
+        The continuous integration ensures that our tests run on the following
+        platforms:
+        
+        -  Python 2.6, 2.7
+        -  Python 3.2, 3.3
+        -  pypy
+        
+        It might also work on Python 2.5, but is not automatically tested with this
+        version.
+        
+        We also track the coverage of our tests with coveralls.io
+        
+        |Coverage|
+        
+        Use `coverage <https://pypi.python.org/pypi/coverage>`__ to generate local
+        coverage reports like this:
+        
+        ::
+        
+            coverage run setup.py nosetests
+        
+        Note: on some platforms (e.g. Ubuntu) the executable is called
+        ``python-coverage``.
+        
+        
+        Contribution and feedback
+        -------------------------
+        
+        *obsub* is developed on `github <https://github.com/aepsil0n/obsub>`__.
+        
+        If you have any questions about this software or encounter bugs, you're welcome
+        to open a `new issue on github <https://github.com/aepsil0n/obsub/issues/new>`__.
+        
+        In case you do not want to use github for some reason, you can alternatively
+        send an email one of us:
+        
+        - `Eduard Bopp <eduard.bopp at aepsil0n.de>`__
+        - `André-Patrick Bubel <code at andre-bubel.de>`__
+        - `Thomas Gläßle <t_glaessle at gmx.de>`__
+        
+        Feel free to contribute patches as pull requests as you see fit. Try to be
+        consistent with PEP 8 guidelines as far as possible and test everything.
+        Otherwise, your commit messages should start with a capitalized verb for
+        consistency. Unless your modification is completely trivial, also add a message
+        body to your commit.
+        
+        
+        
+        Credits
+        -------
+        
+        Thanks to Jason Orendorff on for the idea on stackoverflow. I also want
+        to thank @coldfix and @Moredread for contributions and feedback.
+        
+        .. |Downloads| image:: https://pypip.in/d/obsub/badge.png
+           :target: https://pypi.python.org/pypi/obsub/
+           :alt: Downloads
+        .. |Version| image:: https://pypip.in/v/obsub/badge.png
+           :target: https://pypi.python.org/pypi/obsub/
+           :alt: Latest Version
+        .. |License| image:: https://pypip.in/license/obsub/badge.png
+           :target: https://pypi.python.org/pypi/obsub/
+           :alt: License
+        .. |Build Status| image:: https://api.travis-ci.org/aepsil0n/obsub.png?branch=master
+           :target: https://travis-ci.org/aepsil0n/obsub
+        .. |Coverage| image:: https://coveralls.io/repos/aepsil0n/obsub/badge.png?branch=master
+           :target: https://coveralls.io/r/aepsil0n/obsub
+        
+        Changelog
+        ---------
+        
+        v0.2
+        ~~~~
+        
+        From a user perspective the preservation of function signatures and a couple of
+        bug fixes are probably most relevant. Python 2.5 is no longer tested by
+        continuous integration, though we try to avoid unnecessary changes that might
+        break backwards compatibility.
+        
+        In addition, there are quite a number of changes that mostly concern
+        developers.
+        
+        - Function signatures are now preserved correctly by the event decorator. This
+          is true only for python3. On python2 there is no support for default
+          arguments, currently
+        - Some fixes to memory handling and tests thereof. This includes a more generic
+          handling of the garbage collection process within the test suite to make it
+          pass on pypy, too.
+        - Massive refactoring of test suite from one very long doctest to more focussed
+          unit tests.
+        - The documentation has been converted from Markdown to reStructuredText, since
+          it is compatible with both PyPI and GitHub.
+        - Various improvements and some streamlining of the documentation.
+        - Fix package name in license.
+        - Continuous integration now includes coveralls.io support.
+        - Support for Python 2.5 is no longer tested using Travis CI, since they have
+          dropped support for this version.
+        
+        
+        v0.1.1
+        ~~~~~~
+        
+        - Add __all__ attribute to module
+        - Fix a couple of documentation issues
+        
+        
+        v0.1
+        ~~~~
+        
+        *Initial release*
+        
+Platform: UNKNOWN
+Classifier: Development Status :: 4 - Beta
+Classifier: Intended Audience :: Developers
+Classifier: License :: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
+Classifier: Operating System :: OS Independent
+Classifier: Programming Language :: Python
+Classifier: Topic :: Software Development
diff --git a/README.rst b/README.rst
new file mode 100644
index 0000000..f91faac
--- /dev/null
+++ b/README.rst
@@ -0,0 +1,144 @@
+obsub
+=====
+
+|Build Status| |Coverage| |Version| |Downloads| |License|
+
+Small python module that implements the observer pattern via a
+decorator.
+
+
+Description
+-----------
+
+This is based on a `thread on stackoverflow
+<http://stackoverflow.com/questions/1904351/python-observer-pattern-examples-tips>`_
+(the example of C#-like events by Jason Orendorff), so I don't take any
+credit for the idea. I merely made a fancy module with documentation and
+tests out of it, since I needed it in a bigger project. It is quite
+handy and I've been using it in a couple of projects, which require some
+sort of event handling.
+
+Thus it is `licensed as
+CC0 <http://creativecommons.org/publicdomain/zero/1.0/>`__, so basically
+do-whatever-you-want to the extent legally possible.
+
+
+Installation
+------------
+
+*obsub* is available on PyPI, so you can simply install it using
+``pip install obsub`` or you do it manually using ``setup.py`` as with
+any python package.
+
+
+Usage
+-----
+
+The ``event`` decorator from the ``obsub`` module is used as follows:
+
+.. code:: python
+
+    from obsub import event
+
+    # Define a class with an event
+    class Subject(object):
+        @event
+        def on_stuff(self, arg):
+            print('Stuff {} happens'.format(arg))
+
+    # Now define an event handler, the observer
+    def handler(subject, arg):
+        print('Stuff {} is handled'.format(arg))
+
+    # Wire everything up...
+    sub = Subject()
+    sub.on_stuff += handler
+
+    # And try it!
+    sub.on_stuff('foo')
+
+You should now get both print messages from the event itself and the
+event handler function, like so:
+
+::
+
+    Stuff foo happens
+    Stuff foo is handled
+
+
+Continuous integration
+----------------------
+
+For the fun of it, `Travis CI <https://travis-ci.org/aepsil0n/obsub>`__
+is used for continuous integration. As long as everything is fine, the
+button below should be green and shiny!
+
+|Build Status|
+
+The continuous integration ensures that our tests run on the following
+platforms:
+
+-  Python 2.6, 2.7
+-  Python 3.2, 3.3
+-  pypy
+
+It might also work on Python 2.5, but is not automatically tested with this
+version.
+
+We also track the coverage of our tests with coveralls.io
+
+|Coverage|
+
+Use `coverage <https://pypi.python.org/pypi/coverage>`__ to generate local
+coverage reports like this:
+
+::
+
+    coverage run setup.py nosetests
+
+Note: on some platforms (e.g. Ubuntu) the executable is called
+``python-coverage``.
+
+
+Contribution and feedback
+-------------------------
+
+*obsub* is developed on `github <https://github.com/aepsil0n/obsub>`__.
+
+If you have any questions about this software or encounter bugs, you're welcome
+to open a `new issue on github <https://github.com/aepsil0n/obsub/issues/new>`__.
+
+In case you do not want to use github for some reason, you can alternatively
+send an email one of us:
+
+- `Eduard Bopp <eduard.bopp at aepsil0n.de>`__
+- `André-Patrick Bubel <code at andre-bubel.de>`__
+- `Thomas Gläßle <t_glaessle at gmx.de>`__
+
+Feel free to contribute patches as pull requests as you see fit. Try to be
+consistent with PEP 8 guidelines as far as possible and test everything.
+Otherwise, your commit messages should start with a capitalized verb for
+consistency. Unless your modification is completely trivial, also add a message
+body to your commit.
+
+
+
+Credits
+-------
+
+Thanks to Jason Orendorff on for the idea on stackoverflow. I also want
+to thank @coldfix and @Moredread for contributions and feedback.
+
+.. |Downloads| image:: https://pypip.in/d/obsub/badge.png
+   :target: https://pypi.python.org/pypi/obsub/
+   :alt: Downloads
+.. |Version| image:: https://pypip.in/v/obsub/badge.png
+   :target: https://pypi.python.org/pypi/obsub/
+   :alt: Latest Version
+.. |License| image:: https://pypip.in/license/obsub/badge.png
+   :target: https://pypi.python.org/pypi/obsub/
+   :alt: License
+.. |Build Status| image:: https://api.travis-ci.org/aepsil0n/obsub.png?branch=master
+   :target: https://travis-ci.org/aepsil0n/obsub
+.. |Coverage| image:: https://coveralls.io/repos/aepsil0n/obsub/badge.png?branch=master
+   :target: https://coveralls.io/r/aepsil0n/obsub
diff --git a/obsub.egg-info/PKG-INFO b/obsub.egg-info/PKG-INFO
new file mode 100644
index 0000000..b8be906
--- /dev/null
+++ b/obsub.egg-info/PKG-INFO
@@ -0,0 +1,203 @@
+Metadata-Version: 1.1
+Name: obsub
+Version: 0.2
+Summary: Implementation of the observer pattern via a decorator
+Home-page: https://github.com/aepsil0n/obsub
+Author: Eduard Bopp
+Author-email: eduard.bopp at aepsil0n.de
+License: Public Domain
+Description: obsub
+        =====
+        
+        |Build Status| |Coverage| |Version| |Downloads| |License|
+        
+        Small python module that implements the observer pattern via a
+        decorator.
+        
+        
+        Description
+        -----------
+        
+        This is based on a `thread on stackoverflow
+        <http://stackoverflow.com/questions/1904351/python-observer-pattern-examples-tips>`_
+        (the example of C#-like events by Jason Orendorff), so I don't take any
+        credit for the idea. I merely made a fancy module with documentation and
+        tests out of it, since I needed it in a bigger project. It is quite
+        handy and I've been using it in a couple of projects, which require some
+        sort of event handling.
+        
+        Thus it is `licensed as
+        CC0 <http://creativecommons.org/publicdomain/zero/1.0/>`__, so basically
+        do-whatever-you-want to the extent legally possible.
+        
+        
+        Installation
+        ------------
+        
+        *obsub* is available on PyPI, so you can simply install it using
+        ``pip install obsub`` or you do it manually using ``setup.py`` as with
+        any python package.
+        
+        
+        Usage
+        -----
+        
+        The ``event`` decorator from the ``obsub`` module is used as follows:
+        
+        .. code:: python
+        
+            from obsub import event
+        
+            # Define a class with an event
+            class Subject(object):
+                @event
+                def on_stuff(self, arg):
+                    print('Stuff {} happens'.format(arg))
+        
+            # Now define an event handler, the observer
+            def handler(subject, arg):
+                print('Stuff {} is handled'.format(arg))
+        
+            # Wire everything up...
+            sub = Subject()
+            sub.on_stuff += handler
+        
+            # And try it!
+            sub.on_stuff('foo')
+        
+        You should now get both print messages from the event itself and the
+        event handler function, like so:
+        
+        ::
+        
+            Stuff foo happens
+            Stuff foo is handled
+        
+        
+        Continuous integration
+        ----------------------
+        
+        For the fun of it, `Travis CI <https://travis-ci.org/aepsil0n/obsub>`__
+        is used for continuous integration. As long as everything is fine, the
+        button below should be green and shiny!
+        
+        |Build Status|
+        
+        The continuous integration ensures that our tests run on the following
+        platforms:
+        
+        -  Python 2.6, 2.7
+        -  Python 3.2, 3.3
+        -  pypy
+        
+        It might also work on Python 2.5, but is not automatically tested with this
+        version.
+        
+        We also track the coverage of our tests with coveralls.io
+        
+        |Coverage|
+        
+        Use `coverage <https://pypi.python.org/pypi/coverage>`__ to generate local
+        coverage reports like this:
+        
+        ::
+        
+            coverage run setup.py nosetests
+        
+        Note: on some platforms (e.g. Ubuntu) the executable is called
+        ``python-coverage``.
+        
+        
+        Contribution and feedback
+        -------------------------
+        
+        *obsub* is developed on `github <https://github.com/aepsil0n/obsub>`__.
+        
+        If you have any questions about this software or encounter bugs, you're welcome
+        to open a `new issue on github <https://github.com/aepsil0n/obsub/issues/new>`__.
+        
+        In case you do not want to use github for some reason, you can alternatively
+        send an email one of us:
+        
+        - `Eduard Bopp <eduard.bopp at aepsil0n.de>`__
+        - `André-Patrick Bubel <code at andre-bubel.de>`__
+        - `Thomas Gläßle <t_glaessle at gmx.de>`__
+        
+        Feel free to contribute patches as pull requests as you see fit. Try to be
+        consistent with PEP 8 guidelines as far as possible and test everything.
+        Otherwise, your commit messages should start with a capitalized verb for
+        consistency. Unless your modification is completely trivial, also add a message
+        body to your commit.
+        
+        
+        
+        Credits
+        -------
+        
+        Thanks to Jason Orendorff on for the idea on stackoverflow. I also want
+        to thank @coldfix and @Moredread for contributions and feedback.
+        
+        .. |Downloads| image:: https://pypip.in/d/obsub/badge.png
+           :target: https://pypi.python.org/pypi/obsub/
+           :alt: Downloads
+        .. |Version| image:: https://pypip.in/v/obsub/badge.png
+           :target: https://pypi.python.org/pypi/obsub/
+           :alt: Latest Version
+        .. |License| image:: https://pypip.in/license/obsub/badge.png
+           :target: https://pypi.python.org/pypi/obsub/
+           :alt: License
+        .. |Build Status| image:: https://api.travis-ci.org/aepsil0n/obsub.png?branch=master
+           :target: https://travis-ci.org/aepsil0n/obsub
+        .. |Coverage| image:: https://coveralls.io/repos/aepsil0n/obsub/badge.png?branch=master
+           :target: https://coveralls.io/r/aepsil0n/obsub
+        
+        Changelog
+        ---------
+        
+        v0.2
+        ~~~~
+        
+        From a user perspective the preservation of function signatures and a couple of
+        bug fixes are probably most relevant. Python 2.5 is no longer tested by
+        continuous integration, though we try to avoid unnecessary changes that might
+        break backwards compatibility.
+        
+        In addition, there are quite a number of changes that mostly concern
+        developers.
+        
+        - Function signatures are now preserved correctly by the event decorator. This
+          is true only for python3. On python2 there is no support for default
+          arguments, currently
+        - Some fixes to memory handling and tests thereof. This includes a more generic
+          handling of the garbage collection process within the test suite to make it
+          pass on pypy, too.
+        - Massive refactoring of test suite from one very long doctest to more focussed
+          unit tests.
+        - The documentation has been converted from Markdown to reStructuredText, since
+          it is compatible with both PyPI and GitHub.
+        - Various improvements and some streamlining of the documentation.
+        - Fix package name in license.
+        - Continuous integration now includes coveralls.io support.
+        - Support for Python 2.5 is no longer tested using Travis CI, since they have
+          dropped support for this version.
+        
+        
+        v0.1.1
+        ~~~~~~
+        
+        - Add __all__ attribute to module
+        - Fix a couple of documentation issues
+        
+        
+        v0.1
+        ~~~~
+        
+        *Initial release*
+        
+Platform: UNKNOWN
+Classifier: Development Status :: 4 - Beta
+Classifier: Intended Audience :: Developers
+Classifier: License :: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
+Classifier: Operating System :: OS Independent
+Classifier: Programming Language :: Python
+Classifier: Topic :: Software Development
diff --git a/obsub.egg-info/SOURCES.txt b/obsub.egg-info/SOURCES.txt
new file mode 100644
index 0000000..1b773e6
--- /dev/null
+++ b/obsub.egg-info/SOURCES.txt
@@ -0,0 +1,15 @@
+CHANGELOG.rst
+LICENSE.rst
+MANIFEST.in
+README.rst
+obsub.py
+setup.cfg
+setup.py
+obsub.egg-info/PKG-INFO
+obsub.egg-info/SOURCES.txt
+obsub.egg-info/dependency_links.txt
+obsub.egg-info/top_level.txt
+test/test_core.py
+test/test_signature.py
+test/test_weakref.py
+test/py3/test_signature.py
\ No newline at end of file
diff --git a/obsub.egg-info/dependency_links.txt b/obsub.egg-info/dependency_links.txt
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/obsub.egg-info/dependency_links.txt
@@ -0,0 +1 @@
+
diff --git a/obsub.egg-info/top_level.txt b/obsub.egg-info/top_level.txt
new file mode 100644
index 0000000..c0f35fd
--- /dev/null
+++ b/obsub.egg-info/top_level.txt
@@ -0,0 +1 @@
+obsub
diff --git a/obsub.py b/obsub.py
new file mode 100644
index 0000000..dcad56c
--- /dev/null
+++ b/obsub.py
@@ -0,0 +1,222 @@
+'''
+This is an implementation of the observer pattern.  It uses function
+decorators to achieve the desired event registration mechanism.
+
+For further reference, see
+
+http://en.wikipedia.org/wiki/Observer_pattern
+
+The idea is based on this thread:
+http://stackoverflow.com/questions/1904351/python-observer-pattern-examples-tips
+
+'''
+
+import functools
+import inspect
+
+try:
+    # use python3 signatures if available
+    # this takes care of enforcing the correct signature at call time and 
+    # provides the correct default arguments
+    from inspect import signature
+except ImportError: # pragma: no cover
+    # python2 has no support for signatures
+    def signature(fn):
+        return None
+
+__all__ = ['event']
+__version__ = '0.2'
+
+
+class event(object):
+    '''
+    This class serves as a utility to decorate a function as an event.
+
+    The following example demonstrates its functionality in an abstract way.
+    A class method can be decorated as follows:
+
+    >>> class A(object):
+    ...     def __init__(self, name):
+    ...         self.name = name
+    ...
+    ...     @event
+    ...     def progress(self, first, second):
+    ...         print("Doing something...")
+
+    A.progress is the event.  It is triggered after executing the code in the
+    decorated progress routine.
+
+    Now that we have a class with some event, let's create an event handler.
+
+    >>> def handler(self, first, second):
+    ...     print("%s %s and %s!" % (first, self.name, second))
+
+    Note that the handler (and signal calls) must have the signature defined
+    by the decorated event method.
+
+    This handler only greets the object that triggered the event by using its
+    name attribute.  Let's create some instances of A and register our new
+    event handler to their progress event.
+
+    >>> a = A("Foo")
+    >>> b = A("Bar")
+    >>> a.progress += handler
+    >>> b.progress += handler
+
+    Now everything has been setup.  When we call the method, the event will be
+    triggered:
+
+    >>> a.progress("Hello", "World")
+    Doing something...
+    Hello Foo and World!
+    >>> b.progress(second="Others", first="Hi")
+    Doing something...
+    Hi Bar and Others!
+
+    What happens if we disobey the call signature?
+
+    >>> c = A("World")
+    >>> c.progress(second="World")  # doctest: +IGNORE_EXCEPTION_DETAIL
+    Traceback (most recent call last):
+    TypeError: progress() missing 1 required positional argument: 'first'
+
+    Class based access is possible as well:
+
+    >>> A.progress(a, "Hello", "Y")
+    Doing something...
+    Hello Foo and Y!
+
+    Bound methods keep the instance alive:
+
+    >>> f = a.progress
+    >>> import weakref, gc
+    >>> wr = weakref.ref(a)
+    >>> del a
+    >>> c=gc.collect()
+    >>> assert wr() is not None
+    >>> f("Hi", "Z")
+    Doing something...
+    Hi Foo and Z!
+
+    If we delete the hard reference to the bound method and run the garbage
+    collector (to make sure it is run at all), the object will be gone:
+
+    >>> del f
+    >>> c=gc.collect()
+    >>> assert wr() is None
+
+    '''
+
+    def __init__(self, function):
+        '''
+        Constructor.
+
+        * function -- The function to be wrapped by the decorator.
+
+        '''
+        # Copy docstring and other attributes from function
+        functools.update_wrapper(self, function)
+        self.__signature__ = signature(function)
+        # Used to enforce call signature even when no slot is connected.
+        # Can also execute code (called before handlers)
+        self.__function = function
+
+    def __set__(self, instance, value):
+        '''
+        This is a NOP preventing that a boundevent instance is stored.
+
+        This prevents  operations like  `a.progress += handler`  to have
+        side effects that result in a cyclic reference.
+
+        http://stackoverflow.com/questions/18287336/memory-leak-when-invoking-iadd-via-get-without-using-temporary
+
+        '''
+        pass
+
+    def __get__(self, instance, owner):
+        '''
+        Overloaded __get__ method.  Defines the object resulting from
+        a method/function decorated with @event.
+
+        See http://docs.python.org/reference/datamodel.html?highlight=__get__#object.__get__
+        for a detailed explanation of what this special method usually does.
+
+        * instance -- The instance of event invoked.
+        * owner -- The owner class.
+
+        '''
+        # this case corresponds to access via the owner class:
+        if instance is None:
+            @functools.wraps(self.__function)
+            def wrapper(instance, *args, **kwargs):
+                return self.__get__(instance, owner)(*args, **kwargs)
+        else:
+            wrapper = functools.wraps(self.__function)(boundevent(instance, self.__function))
+        wrapper.__signature__ = self.__signature__
+        return wrapper
+
+
+class boundevent(object):
+    '''Private helper class for event system.'''
+
+    def __init__(self, instance, function):
+        '''
... 412 lines suppressed ...

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/obsub.git



More information about the Python-modules-commits mailing list