Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
decorator = service.depfilter(
aioxmpp.stream.StanzaStream,
"some_filter",
)
decorator(cb)
spec, = cb._aioxmpp_service_handlers
self.assertNotIn(
aioxmpp.stream.StanzaStream,
spec.require_deps,
)
class Testattrsignal(unittest.TestCase):
class DescriptorValue:
signal = callbacks.Signal()
sync = callbacks.SyncSignal()
class Descriptor(service.Descriptor):
def init_cm(self, instance):
raise NotImplementedError
@property
def value_type(self):
return Testattrsignal.DescriptorValue
def setUp(self):
self.descriptor = self.Descriptor()
self.decorator = service.attrsignal(
self.descriptor,
.. note::
If you are looking for a "on_conversation_removed" event or similar,
there is none. You should use the
:meth:`.AbstractConversation.on_exit` event of the `conversation`.
.. autoattribute:: conversations
For :term:`Conversation Implementations `, the
following methods are intended; they should not be used by applications.
.. automethod:: _add_conversation
"""
on_conversation_added = aioxmpp.callbacks.Signal()
def __init__(self, client, **kwargs):
super().__init__(client, **kwargs)
self._conversations = []
@property
def conversations(self):
"""
Return an iterable of conversations in which the local client is
participating.
"""
return self._conversations
def _handle_conversation_exit(self, conv, *args, **kwargs):
self._conversations.remove(conv)
PADDING = 2
SPACING = 2
LEFT_PADDING = PADDING + 6
TAG_MARGIN = 2
TAG_PADDING = 2
TAG_FONT_SIZE = 0.9
MIN_TAG_WIDTH = 16
NAME_FONT_SIZE = 1.1
MAX_AVATAR_SIZE = 48
SMALL_AVATAR_SIZE = 24
AVATAR_SMALL_THRESHOLD = 120
AVATAR_ZERO_THRESHOLD = 60
on_tag_clicked = aioxmpp.callbacks.Signal()
def __init__(self, avatar_manager, parent=None):
super().__init__(parent=parent)
self.avatar_manager = avatar_manager
self._cache = aioxmpp.cache.LRUDict()
self._cache.maxsize = 128
def _get_fonts(self, base_font):
name_font = Qt.QFont(base_font)
name_font.setWeight(Qt.QFont.Bold)
name_font.setPointSizeF(name_font.pointSizeF() * self.NAME_FONT_SIZE)
tag_font = Qt.QFont(base_font)
tag_font.setPointSizeF(tag_font.pointSizeF() * self.TAG_FONT_SIZE)
return name_font, tag_font
Miscellaneous:
.. attribute:: logger
The :class:`logging.Logger` instance which is used by the
:class:`Client`. This is the `logger` passed to the constructor or a
logger derived from the fully qualified name of the class.
.. versionadded:: 0.6
The :attr:`logger` attribute was added.
"""
on_failure = callbacks.Signal()
on_stopped = callbacks.Signal()
on_stream_destroyed = callbacks.Signal()
on_stream_suspended = callbacks.Signal()
on_stream_established = callbacks.Signal()
before_stream_established = callbacks.SyncSignal()
def __init__(self,
local_jid,
security_layer,
*,
negotiation_timeout=timedelta(seconds=60),
max_initial_attempts=4,
override_peer=[],
loop=None,
logger=None):
super().__init__()
.. versionchanged:: 0.8
This class was formerly known as :class:`aioxmpp.roster.Service`. It
is still available under that name, but the alias will be removed in
1.0.
"""
ORDER_AFTER = [
aioxmpp.dispatcher.SimplePresenceDispatcher,
]
on_initial_roster_received = callbacks.Signal()
on_entry_name_changed = callbacks.Signal()
on_entry_subscription_state_changed = callbacks.Signal()
on_entry_removed = callbacks.Signal()
on_entry_added = callbacks.Signal()
on_entry_added_to_group = callbacks.Signal()
on_entry_removed_from_group = callbacks.Signal()
on_group_added = callbacks.Signal()
on_group_removed = callbacks.Signal()
on_subscribed = callbacks.Signal()
on_subscribe = callbacks.Signal()
on_unsubscribed = callbacks.Signal()
on_unsubscribe = callbacks.Signal()
def __init__(self, client, **kwargs):
super().__init__(client, **kwargs)
self._bse_token = client.before_stream_established.connect(
:param stanza: The received stanza.
:type stanza: :class:`aioxmpp.Presence`
.. seealso::
:class:`aioxmpp.dispatcher.SimplePresenceDispatcher`
for a service which allows to register callbacks for presences
based on the sender and type of the message.
.. versionadded:: 0.9
"""
_ALLOW_ENUM_COERCION = True
on_failure = callbacks.Signal()
on_stream_destroyed = callbacks.Signal()
on_stream_established = callbacks.Signal()
on_message_received = callbacks.Signal()
on_presence_received = callbacks.Signal()
def __init__(self,
local_jid=None,
*,
loop=None,
base_logger=logging.getLogger("aioxmpp")):
super().__init__()
self._loop = loop or asyncio.get_event_loop()
self._logger = base_logger.getChild("StanzaStream")
self._task = None
.. automethod:: block_jids
.. automethod:: unblock_jids
.. automethod:: unblock_all
"""
ORDER_AFTER = [aioxmpp.DiscoClient]
def __init__(self, client, **kwargs):
super().__init__(client, **kwargs)
self._blocklist = None
self._lock = asyncio.Lock()
self._disco = self.dependencies[aioxmpp.DiscoClient]
on_jids_blocked = callbacks.Signal()
on_jids_unblocked = callbacks.Signal()
on_initial_blocklist_received = callbacks.Signal()
@asyncio.coroutine
def _check_for_blocking(self):
server_info = yield from self._disco.query_info(
self.client.local_jid.replace(
resource=None,
localpart=None,
)
)
if namespaces.xep0191 not in server_info.features:
self._blocklist = None
raise RuntimeError("server does not support blocklists!")
This signal emits when a feature or identity is registered or
unregistered.
As mentioned, bare :class:`Node` objects have no items; there are
subclasses of :class:`Node` which support items:
====================== ==================================================
:class:`StaticNode` Support for a list of :class:`.xso.Item` instances
:class:`.DiscoServer` Support for "mountpoints" for node subtrees
====================== ==================================================
"""
STATIC_FEATURES = frozenset({namespaces.xep0030_info})
on_info_changed = aioxmpp.callbacks.Signal()
def __init__(self):
super().__init__()
self._identities = {}
self._features = set()
def iter_identities(self, stanza=None):
"""
Return an iterator of tuples describing the identities of the node.
:param stanza: The IQ request stanza
:type stanza: :class:`~aioxmpp.IQ` or :data:`None`
:rtype: iterable of (:class:`str`, :class:`str`, :class:`str` or
:data:`None`, :class:`str` or :data:`None`) tuples
:return: :xep:`30` identities of this node
.. signal:: on_closed()
Emits when the tracker is closed.
.. automethod:: close
.. automethod:: set_timeout
"Protected" interface:
.. automethod:: _set_state
"""
on_closed = aioxmpp.callbacks.Signal()
on_state_changed = aioxmpp.callbacks.Signal()
def __init__(self):
super().__init__()
self._state = MessageState.IN_TRANSIT
self._response = None
self._closed = False
@property
def state(self):
"""
The current state of the tracking. Read-only.
"""
return self._state
@property
def response(self):
service would be forced to send a malformed response or reply with
````.
After having added another identity, that default identity can be
removed.
Other :class:`~.disco.Node` instances can be registered with the service
using the following methods:
.. automethod:: mount_node
.. automethod:: unmount_node
"""
on_info_result = aioxmpp.callbacks.Signal()
def __init__(self, client, **kwargs):
super().__init__(client, **kwargs)
self._node_mounts = {
None: self
}
self.register_identity(
"client", "bot",
names={
structs.LanguageTag.fromstr("en"): "aioxmpp default identity"
}
)
@aioxmpp.service.iq_handler(