⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.30
Server IP:
45.79.8.107
Server:
Linux localhost 5.15.0-140-generic #150-Ubuntu SMP Sat Apr 12 06:00:09 UTC 2025 x86_64
Server Software:
nginx/1.18.0
PHP Version:
8.1.2-1ubuntu2.21
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
lib
/
python3
/
dist-packages
/
blinker
/
__pycache__
/
View File Name :
base.cpython-310.pyc
o RѰU? @ s d Z ddlmZ ddlmZ ddlmZmZmZm Z m Z mZmZ edZ de _ dZG dd deZed ZG d d deZG dd d eZG dd deZe jZdS )a+ Signals and events. A small implementation of signals, inspired by a snippet of Django signal API client code seen in a blog post. Signals are first-class objects and each manages its own receivers and message emission. The :func:`signal` function provides singleton behavior for named signals. )warn)WeakValueDictionary) WeakTypescontextmanagerdefaultdicthashable_identity lazy_property referencesymbolANYzToken for "any sender".c @ s e Zd ZdZeZedd Zedd Zd%ddZed fd dZ d&d dZ eefddZefddZ dd Zdd Zdd ZefddZdd Zdd Zdd Zd!d" Zd#d$ ZdS )'SignalzA notification emitter.c C t ddS )zEmitted after each :meth:`connect`. The signal sender is the signal instance, and the :meth:`connect` arguments are passed through: *receiver*, *sender*, and *weak*. .. versionadded:: 1.2 z"Emitted after a receiver connects.docr self r ./usr/lib/python3/dist-packages/blinker/base.pyreceiver_connected% s zSignal.receiver_connectedc C r )a Emitted after :meth:`disconnect`. The sender is the signal instance, and the :meth:`disconnect` arguments are passed through: *receiver* and *sender*. Note, this signal is emitted **only** when :meth:`disconnect` is called explicitly. The disconnect signal can not be emitted by an automatic disconnect (due to a weakly referenced receiver or sender going out of scope), as the receiver and/or sender instances are no longer available for use at the time this signal would be emitted. An alternative approach is available by subscribing to :attr:`receiver_connected` and setting up a custom weakref cleanup callback on weak receivers and senders. .. versionadded:: 1.2 z%Emitted after a receiver disconnects.r r r r r r receiver_disconnected1 s zSignal.receiver_disconnectedNc C s. |r|| _ i | _tt| _tt| _i | _dS )zt :param doc: optional. If provided, will be assigned to the signal's __doc__ attribute. N)__doc__ receiversr set_by_receiver _by_sender _weak_senders)r r r r r __init__I s zSignal.__init__Tc C s6 t |}|rt|| j}||_n|}|tu rt}nt |}| j|| | j| | | j | | ~|tur[|| jvr[zt|| j}||_ W n tyR Y n w | j|| ~d| jv r{| jjr{z| jj| |||d W n | || tjr| turztj| |||d W |S | || |S )aa Connect *receiver* to signal events sent by *sender*. :param receiver: A callable. Will be invoked by :meth:`send` with `sender=` as a single positional argument and any \*\*kwargs that were provided to a call to :meth:`send`. :param sender: Any object or :obj:`ANY`, defaults to ``ANY``. Restricts notifications delivered to *receiver* to only those :meth:`send` emissions sent by *sender*. If ``ANY``, the receiver will always be notified. A *receiver* may be connected to multiple *sender* values on the same Signal through multiple calls to :meth:`connect`. :param weak: If true, the Signal will hold a weakref to *receiver* and automatically disconnect when *receiver* goes out of scope or is garbage collected. Defaults to True. r )receiversenderweak)Zreceiver_argZ sender_argZweak_arg)r r _cleanup_receiverreceiver_idr ANY_IDr setdefaultr addr r _cleanup_sender sender_id TypeError__dict__r send disconnect)r r r r r" receiver_refr' sender_refr r r connect\ sZ zSignal.connectFc s fdd}|S )aK Connect the decorated function as a receiver for *sender*. :param sender: Any object or :obj:`ANY`. The decorated function will only receive :meth:`send` emissions sent by *sender*. If ``ANY``, the receiver will always be notified. A function may be decorated multiple times with differing *sender* values. :param weak: If true, the Signal will hold a weakref to the decorated function and automatically disconnect when *receiver* goes out of scope or is garbage collected. Unlike :meth:`connect`, this defaults to False. The decorated function will be invoked by :meth:`send` with `sender=` as a single positional argument and any \*\*kwargs that were provided to the call to :meth:`send`. .. versionadded:: 1.1 c s | | S N)r. )fnr r r r r decorator s z%Signal.connect_via.
.decoratorr )r r r r2 r r1 r connect_via s zSignal.connect_viac c s> | j ||dd zdV W n | | | | dS )a Execute a block with the signal temporarily connected to *receiver*. :param receiver: a receiver callable :param sender: optional, a sender to filter on This is a context manager for use in the ``with`` statement. It can be useful in unit tests. *receiver* is connected to the signal for the duration of the ``with`` block, and will be disconnected automatically when exiting the block: .. testsetup:: from __future__ import with_statement from blinker import Signal on_ready = Signal() receiver = lambda sender: None .. testcode:: with on_ready.connected_to(receiver): # do stuff on_ready.send(123) .. versionadded:: 1.1 F)r r N)r. r+ r r r r r r connected_to s zSignal.connected_toc C s t dt | ||S )ag An alias for :meth:`connected_to`. :param receiver: a receiver callable :param sender: optional, a sender to filter on .. versionadded:: 0.9 .. versionchanged:: 1.1 Renamed to :meth:`connected_to`. ``temporarily_connected_to`` was deprecated in 1.2 and will be removed in a subsequent version. zAtemporarily_connected_to is deprecated; use connected_to instead.)r DeprecationWarningr5 r4 r r r temporarily_connected_to s zSignal.temporarily_connected_toc sZ t dkr dnt dkrtdt d | js g S fdd| D S )a Emit this signal on behalf of *sender*, passing on \*\*kwargs. Returns a list of 2-tuples, pairing receivers with their return value. The ordering of receiver notification is undefined. :param \*sender: Any object or ``None``. If omitted, synonymous with ``None``. Only accepts one positional argument. :param \*\*kwargs: Data to be sent to receivers. r N z5send() accepts only one positional argument, %s givenc s g | ]}||fi fqS r r ).0r kwargsr r r
s zSignal.send.
.
)lenr( r receivers_for)r r r; r r: r r* s zSignal.sendc C s2 | j sdS | jt rdS |tu rdS t|| jv S )zTrue if there is probably a receiver for *sender*. Performs an optimistic check only. Does not guarantee that all weakly referenced receivers are still alive. See :meth:`receivers_for` for a stronger search. FT)r r r# r r )r r r r r has_receivers_for s zSignal.has_receivers_forc c s | j rGt|}|| jv r| jt | j| B }n| jt }|D ]'}| j |}|du r.q!t|trC| }|du rA| |t q!|}|V q!dS dS )z2Iterate all live receivers listening for *sender*.N) r r r r# copyget isinstancer _disconnect)r r r' Zidsr" r Zstrongr r r r> s* zSignal.receivers_forc C sZ |t u rt}nt|}t|}| || d| jv r)| jjr+| jj| ||d dS dS dS )a Disconnect *receiver* from this signal's events. :param receiver: a previously :meth:`connected
` callable :param sender: a specific sender to disconnect from, or :obj:`ANY` to disconnect from all senders. Defaults to ``ANY``. r )r r N)r r# r rC r) r r r* )r r r r' r" r r r r+ 3 s zSignal.disconnectc C sf |t kr!| j|dr| j D ]}|| q| j|d d S | j| | | j| | d S )NF)r# r popr valuesdiscardr )r r" r' bucketr r r rC I s zSignal._disconnectc C s | |jt dS )z'Disconnect a receiver from all senders.N)rC r" r# )r r, r r r r! S s zSignal._cleanup_receiverc C sH |j }|tks J | j|d | j|dD ] }| j| | qdS )z'Disconnect all receivers from a sender.Nr )r' r# r rD r r rF )r r- r' r" r r r r&