{"id":13501277,"url":"https://github.com/SatelliteQE/blinker_herald","last_synced_at":"2025-03-29T08:32:18.172Z","repository":{"id":57415595,"uuid":"59910480","full_name":"SatelliteQE/blinker_herald","owner":"SatelliteQE","description":"The Blinker Herald includes helpers to easily emit signals using the excellent blinker library.","archived":true,"fork":false,"pushed_at":"2016-07-01T21:00:44.000Z","size":96,"stargazers_count":7,"open_issues_count":0,"forks_count":5,"subscribers_count":21,"default_branch":"master","last_synced_at":"2025-03-12T13:03:57.983Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SatelliteQE.png","metadata":{"files":{"readme":"README.rst","changelog":"HISTORY.rst","contributing":"CONTRIBUTING.rst","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-05-28T19:10:45.000Z","updated_at":"2023-07-17T20:31:16.000Z","dependencies_parsed_at":"2022-08-27T18:10:38.903Z","dependency_job_id":null,"html_url":"https://github.com/SatelliteQE/blinker_herald","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SatelliteQE%2Fblinker_herald","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SatelliteQE%2Fblinker_herald/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SatelliteQE%2Fblinker_herald/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SatelliteQE%2Fblinker_herald/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SatelliteQE","download_url":"https://codeload.github.com/SatelliteQE/blinker_herald/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246162092,"owners_count":20733351,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T22:01:31.367Z","updated_at":"2025-03-29T08:32:17.150Z","avatar_url":"https://github.com/SatelliteQE.png","language":"Python","readme":"===============================\nBlinker Herald\n===============================\n\n.. image:: docs/The_Herald.jpg\n        :alt: The Herald\n\n.. image:: https://img.shields.io/pypi/v/blinker_herald.svg\n        :target: https://pypi.python.org/pypi/blinker_herald\n\n.. image:: https://travis-ci.org/SatelliteQE/blinker_herald.svg?branch=master\n    :target: https://travis-ci.org/SatelliteQE/blinker_herald\n\n.. image:: https://readthedocs.org/projects/blinker-herald/badge/?version=latest\n        :target: https://readthedocs.org/projects/blinker-herald/?badge=latest\n        :alt: Documentation Status\n\n.. image:: https://coveralls.io/repos/github/SatelliteQE/blinker_herald/badge.svg?branch=master\n        :target: https://coveralls.io/github/SatelliteQE/blinker_herald?branch=master\n        :alt: Coverage\n\nThe Blinker Herald includes helpers to easily emit signals using the excelent\n`blinker`_ library.\n\nDecorate a function or method with :code:`@blinker_herald.emit()`\nand **pre** and **post** signals will be automatically emitted to\nall connected handlers.\n\n* Free software: ISC license\n* Documentation: https://blinker_herald.readthedocs.org.\n\nFeatures\n--------\n\n* All the features provided by `blinker`_\n* `+` an easy decorator :code:`@emit()` to magically emit signals when your functions are called and before it returns a result.\n* A :code:`signals` namespace proxy to discover the signals in your project\n* Customizable for your needs\n\n\nUsage\n-----\nLet's say you have a class and wants to emit a signal for a specific method::\n\n    from blinker_herald import emit\n\n    class SomeClass(object):\n\n        @emit()\n        def do_something(self, arg1):\n            # here is were magically the 'pre' signal will be sent\n            return 'something done'\n            # here is were magically the 'post' signal will be sent\n\n\nusing :code:`@emit` decorator makes blinker_herald to emit a signal for that method\nand now you can connect handlers to capture that signals\n\nYou can capture **pre** signal to manipulate the object::\n\n    SomeClass.do_something.pre.connect\n    def handle_pre(sender, signal_emitter, **kwargs):\n        signal_emitter.foo = 'bar'\n        signal_emitter.do_another_thing()\n\nAnd you can also capture the **post** signal to log the results::\n\n    SomeClass.do_something.post.connect\n    def handle_post(sender, signal_emitter, result, **kwargs):\n        logger.info(\"The method {0} returned {1}\".format(sender, result))\n\n\n.. note::\n\n  Post-signals are only called if there were no exceptions\n  raised during the processing of their related function.\n\nYou can also use the namespace proxy :code:`blinker_herald.signals` to connect\nhandlers to signals, the signal name is the prefix **pre** or **post**\nfollowed by **_** and the method name::\n\n    from blinker_herald import signals\n\n    @signals.pre_do_something.connect\n    def handle_pre(sender, signal_emitter, **kwargs):\n        ...\n\n\nIf you have a lot of subclasses emitting signals with the same name and you\nneed to capture only specific signals, you can specify that you want to listen\nto only one type of sender::\n\n    from blinker_herald import emit, signals, SENDER_CLASS\n    class BaseModel(object):\n        ...\n        @emit(sender=SENDER_CLASS)\n        def create(self, **kwargs):\n            new_instance = my_project.new(self, **kwargs)\n            return new_instance\n\n    class One(BaseModel):\n        pass\n\n    class Two(BaseModel):\n        pass\n\n.. note::\n   By default the sender is always the instance but you can use :code:`SENDER_CLASS`\n   to force the sender to be the **class** another options are **SENDER_CLASS_NAME**,\n   **SENDER_MODULE**, **SENDER_NAME** and you can also pass a string, an object\n   or a lambda receiving the **sender** instance e.g: :code:`@emit(sender=lambda self: self.get_sender())`\n\nUsing :code:`SENDER_CLASS` you can now connect to specific signal::\n\n    from blinker_herald import signals\n\n    @signals.post_create.connect_via(One)\n    def handle_post_only_for_one(sender, signal_emitter, result, **kwargs):\n        # sender is the class One (cls)\n        # signal the instance of the class One (self)\n        # result is the return of the method create\n\nThe above will handle the :code:`create` method signal for the class **One** but not for the class **Two**\n\n\nYou can also be more specific about the signal you want to connect using the\n**__** double underscore to provide method name::\n\n    from blinker_herald import signals\n\n    @signals.module_name__ClassName__post_method_name.connect\n    def handle_post(sender, signal_emitter, result, **kwargs):\n        ...\n\nThe above will connect to the **post** signal emitted by :code:`module_name.ClassName.method_name`\n\n.. note::\n  You don't have to use the pattern above if your project do not have a lot of\n  method name collisions, using only the method name will be just fine for most cases.\n\n\n\nCredits\n-------\n\nThis software was first created by SatelliteQE team to provide signals to\nRobottelo and Nailgun\n\n.. _blinker: http://pypi.python.org/pypi/blinker\n","funding_links":[],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSatelliteQE%2Fblinker_herald","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSatelliteQE%2Fblinker_herald","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSatelliteQE%2Fblinker_herald/lists"}