
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
This package implements a class similar to NSNotificationCenter, a variant of the Observer design pattern, from Objective-C and Swift in Python. To install, (soon you will be able to) just use
pip install notificationcenter
It consists of one singleton class, NotificationCenter, that is used to add observers and to post notifications. To add an observer, you need to do the following:
from notificationcenter import *
# Get the NotifiationCenter
notificationcenter = NotificationCenter()
# Define the function you want to perform when you get the notification.
# It should have parameters of (sender, notification name, notification info)
# And return nothing (It can, but it will be thrown away)
def foo(sender, notification_name, info):
# Do something
# Add an observer
observer = notificationcenter.add_observer(with_block=foo,
for_name="bar")
Now, if we post a notification to the NotificationCenter with the name "bar", as follows, the above function foo will be executed.
notificationcenter = NotificationCenter()
notificationcenter.post_notification(sender=None,
with_name="bar")
When you are no longer using the observer, you should remove it from the NotificationCenter so that the block is no longer executed. It is done as follows:
notificationcenter.remove_oberver(observer)
Detailed documentation is shown below, and the source code is commented.
Adds an observer to listen for certain types of notifications.
with_block: Some function that takes arguments of a sender (any object), notification name (string), and notification info (any object). Any values with_block returns will be ignored.
for_name: String
for_sender: Any object
Removes the given observer from the list of active obserers.
Posts a notification with a given name and (optionally) some additional information.
sender: Any Object
with_name: String
with_info: Any Object
FAQs
Port of NSNotificationCenter functionality to Python
We found that notificationcenter demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.