Bump rumps from 0.3.0 to 0.4.0 (#1896)

* Bump rumps from 0.3.0 to 0.4.0

Bumps [rumps](https://github.com/jaredks/rumps) from 0.3.0 to 0.4.0.
- [Release notes](https://github.com/jaredks/rumps/releases)
- [Changelog](https://github.com/jaredks/rumps/blob/master/CHANGES.rst)
- [Commits](https://github.com/jaredks/rumps/commits)

---
updated-dependencies:
- dependency-name: rumps
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Update rumps==0.4.0

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>

[skip ci]
This commit is contained in:
dependabot[bot] 2022-11-14 11:27:16 -08:00 committed by GitHub
parent b31d75aeee
commit 79cf61c53e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 573 additions and 243 deletions

40
lib/rumps/events.py Normal file
View file

@ -0,0 +1,40 @@
# -*- coding: utf-8 -*-
import traceback
from . import _internal
class EventEmitter(object):
def __init__(self, name):
self.name = name
self.callbacks = set()
self._executor = _internal.call_as_function_or_method
def register(self, func):
self.callbacks.add(func)
return func
def unregister(self, func):
try:
self.callbacks.remove(func)
return True
except KeyError:
return False
def emit(self, *args, **kwargs):
#print('EventEmitter("%s").emit called' % self.name)
for callback in self.callbacks:
try:
self._executor(callback, *args, **kwargs)
except Exception:
traceback.print_exc()
__call__ = register
before_start = EventEmitter('before_start')
on_notification = EventEmitter('on_notification')
on_sleep = EventEmitter('on_sleep')
on_wake = EventEmitter('on_wake')
before_quit = EventEmitter('before_quit')