code string | signature string | docstring string | loss_without_docstring float64 | loss_with_docstring float64 | factor float64 |
|---|---|---|---|---|---|
iq = aioxmpp.stanza.IQ(
type_=aioxmpp.structs.IQType.SET,
to=jid,
payload=pubsub_xso.OwnerRequest(
pubsub_xso.OwnerDelete(
node,
redirect_uri=redirect_uri
)
)
)
yiel... | def delete(self, jid, node, *, redirect_uri=None) | Delete an existing node.
:param jid: Address of the PubSub service.
:type jid: :class:`aioxmpp.JID`
:param node: Name of the PubSub node to delete.
:type node: :class:`str` or :data:`None`
:param redirect_uri: A URI to send to subscribers to indicate a
replacement fo... | 6.257749 | 5.511424 | 1.135414 |
response = yield from self._disco.query_items(
jid,
node=node,
)
result = []
for item in response.items:
if item.jid != jid:
continue
result.append((
item.node,
item.name,
... | def get_nodes(self, jid, node=None) | Request all nodes at a service or collection node.
:param jid: Address of the PubSub service.
:type jid: :class:`aioxmpp.JID`
:param node: Name of the collection node to query
:type node: :class:`str` or :data:`None`
:raises aioxmpp.errors.XMPPError: as returned by the service
... | 4.236388 | 3.340887 | 1.268043 |
iq = aioxmpp.stanza.IQ(
type_=aioxmpp.structs.IQType.GET,
to=jid,
payload=pubsub_xso.OwnerRequest(
pubsub_xso.OwnerAffiliations(node),
)
)
return (yield from self.client.send(iq)) | def get_node_affiliations(self, jid, node) | Return the affiliations of other jids at a node.
:param jid: Address of the PubSub service.
:type jid: :class:`aioxmpp.JID`
:param node: Name of the node to query
:type node: :class:`str`
:raises aioxmpp.errors.XMPPError: as returned by the service
:return: The response ... | 8.045102 | 5.273764 | 1.525495 |
iq = aioxmpp.stanza.IQ(
type_=aioxmpp.structs.IQType.SET,
to=jid,
payload=pubsub_xso.OwnerRequest(
pubsub_xso.OwnerAffiliations(
node,
affiliations=[
pubsub_xso.OwnerAffiliation(
... | def change_node_affiliations(self, jid, node, affiliations_to_set) | Update the affiliations at a node.
:param jid: Address of the PubSub service.
:type jid: :class:`aioxmpp.JID`
:param node: Name of the node to modify
:type node: :class:`str`
:param affiliations_to_set: The affiliations to set at the node.
:type affiliations_to_set: :cla... | 4.217258 | 4.309057 | 0.978696 |
iq = aioxmpp.stanza.IQ(
type_=aioxmpp.structs.IQType.SET,
to=jid,
payload=pubsub_xso.OwnerRequest(
pubsub_xso.OwnerSubscriptions(
node,
subscriptions=[
pubsub_xso.OwnerSubscription(
... | def change_node_subscriptions(self, jid, node, subscriptions_to_set) | Update the subscriptions at a node.
:param jid: Address of the PubSub service.
:type jid: :class:`aioxmpp.JID`
:param node: Name of the node to modify
:type node: :class:`str`
:param subscriptions_to_set: The subscriptions to set at the node.
:type subscriptions_to_set: ... | 4.581012 | 4.740987 | 0.966257 |
iq = aioxmpp.stanza.IQ(
type_=aioxmpp.structs.IQType.SET,
to=jid,
payload=pubsub_xso.OwnerRequest(
pubsub_xso.OwnerPurge(
node
)
)
)
yield from self.client.send(iq) | def purge(self, jid, node) | Delete all items from a node.
:param jid: JID of the PubSub service
:param node: Name of the PubSub node
:type node: :class:`str`
Requires :attr:`.xso.Feature.PURGE`. | 7.59138 | 6.20207 | 1.224007 |
# the following code is a copy of the formal definition of `yield from`
# in PEP 380, with modifications to capture the value sent during yield
_i = iter(receiver)
try:
_y = next(_i)
except StopIteration as _e:
return _e.value
try:
while True:
try:
... | def capture_events(receiver, dest) | Capture all events sent to `receiver` in the sequence `dest`. This is a
generator, and it is best used with ``yield from``. The observable effect
of using this generator with ``yield from`` is identical to the effect of
using `receiver` with ``yield from`` directly (including the return value),
but in a... | 2.9076 | 2.783391 | 1.044625 |
name_stack = []
for ev_type, *ev_args in events:
if ev_type == "start":
name = (ev_args[0], ev_args[1])
dest.startElementNS(name, None, ev_args[2])
name_stack.append(name)
elif ev_type == "end":
name = name_stack.pop()
dest.endEle... | def events_to_sax(events, dest) | Convert an iterable `events` of XSO events to SAX events by calling the
matching SAX methods on `dest` | 2.060775 | 2.139733 | 0.963099 |
result = self
if type_ is not None:
result = self._filter_type(result, type_)
if lang is not None:
result = self._filter_lang(result, lang)
if attrs:
result = self._filter_attrs(result, attrs)
return result | def filter(self, *, type_=None, lang=None, attrs={}) | Return an iterable which produces a sequence of the elements inside
this :class:`XSOList`, filtered by the criteria given as arguments. The
function starts with a working sequence consisting of the whole list.
If `type_` is not :data:`None`, elements which are not an instance of
the giv... | 1.840064 | 2.150239 | 0.855749 |
return list(self.filter(type_=type_, lang=lang, attrs=attrs)) | def filtered(self, *, type_=None, lang=None, attrs={}) | This method is a convencience wrapper around :meth:`filter` which
evaluates the result into a list and returns that list. | 3.92281 | 3.05316 | 1.284836 |
try:
parsed = self.type_.parse(value)
except (TypeError, ValueError):
if self.erroneous_as_absent:
return False
raise
self._set_from_recv(instance, parsed)
return True | def from_value(self, instance, value) | Convert the given value using the set `type_` and store it into
`instance`’ attribute. | 6.569059 | 6.59119 | 0.996642 |
value = self.__get__(instance, type(instance))
if value is None:
return
dest.characters(self.type_.format(value)) | def to_sax(self, instance, dest) | Assign the formatted value stored at `instance`’ attribute to the text
of `el`.
If the `value` is :data:`None`, no text is generated. | 6.309982 | 6.661621 | 0.947214 |
obj = yield from self._process(instance, ev_args, ctx)
self.__set__(instance, obj)
return obj | def from_events(self, instance, ev_args, ctx) | Detect the object to instanciate from the arguments `ev_args` of the
``"start"`` event. The new object is stored at the corresponding
descriptor attribute on `instance`.
This method is suspendable. | 5.939099 | 7.220523 | 0.82253 |
obj = self.__get__(instance, type(instance))
if obj is None:
return
obj.unparse_to_sax(dest) | def to_sax(self, instance, dest) | Take the object associated with this descriptor on `instance` and
serialize it as child into the given :class:`lxml.etree.Element`
`parent`.
If the object is :data:`None`, no content is generated. | 5.641298 | 6.018829 | 0.937275 |
obj = yield from self._process(instance, ev_args, ctx)
self.__get__(instance, type(instance)).append(obj)
return obj | def from_events(self, instance, ev_args, ctx) | Like :meth:`.Child.from_events`, but instead of replacing the attribute
value, the new object is appended to the list. | 6.283134 | 5.139566 | 1.222503 |
# goal: collect all elements starting with the element for which we got
# the start-ev_args in a lxml.etree.Element.
def make_from_args(ev_args, parent):
el = etree.SubElement(parent,
tag_to_str((ev_args[0], ev_args[1])))
for k... | def from_events(self, instance, ev_args, ctx) | Collect the events and convert them to a single XML subtree, which then
gets appended to the list at `instance`. `ev_args` must be the
arguments of the ``"start"`` event of the new child.
This method is suspendable. | 4.692746 | 4.511832 | 1.040098 |
if self.missing is not None:
value = self.missing(instance, ctx)
if value is not None:
self._set_from_code(instance, value)
return
if self.default is _PropBase.NO_DEFAULT:
raise ValueError("missing attribute {} on {}".format(
... | def handle_missing(self, instance, ctx) | Handle a missing attribute on `instance`. This is called whenever no
value for the attribute is found during parsing. The call to
:meth:`missing` is independent of the value of `required`.
If the `missing` callback is not :data:`None`, it is called with the
`instance` and the `ctx` as a... | 4.776878 | 4.161955 | 1.147749 |
value = self.__get__(instance, type(instance))
if value == self.default:
return
d[self.tag] = self.type_.format(value) | def to_dict(self, instance, d) | Override the implementation from :class:`Text` by storing the formatted
value in the XML attribute instead of the character data.
If the value is :data:`None`, no element is generated. | 5.593468 | 5.900886 | 0.947903 |
# goal: take all text inside the child element and collect it as
# attribute value
attrs = ev_args[2]
if attrs and self.attr_policy == UnknownAttrPolicy.FAIL:
raise ValueError("unexpected attribute (at text only node)")
parts = []
while True:
... | def from_events(self, instance, ev_args, ctx) | Starting with the element to which the start event information in
`ev_args` belongs, parse text data. If any children are encountered,
:attr:`child_policy` is enforced (see
:class:`UnknownChildPolicy`). Likewise, if the start event contains
attributes, :attr:`attr_policy` is enforced
... | 8.112682 | 6.585277 | 1.231943 |
value = self.__get__(instance, type(instance))
if value == self.default:
return
if self.declare_prefix is not False and self.tag[0]:
dest.startPrefixMapping(self.declare_prefix, self.tag[0])
dest.startElementNS(self.tag, None, {})
try:
... | def to_sax(self, instance, dest) | Create a child node at `parent` with the tag :attr:`tag`. Set the text
contents to the value of the attribute which this descriptor represents
at `instance`.
If the value is :data:`None`, no element is generated. | 3.213165 | 3.057589 | 1.050882 |
for item in items:
dest[self.key(item)].append(item) | def fill_into_dict(self, items, dest) | Take an iterable of `items` and group it into the given `dest` dict,
using the :attr:`key` function.
The `dest` dict must either already contain the keys which are
generated by the :attr:`key` function for the items in `items`, or must
default them suitably. The values of the affected k... | 4.881105 | 4.750308 | 1.027534 |
tag = ev_args[0], ev_args[1]
cls = self._tag_map[tag]
obj = yield from cls.parse_events(ev_args, ctx)
mapping = self.__get__(instance, type(instance))
mapping[self.key(obj)].append(obj) | def from_events(self, instance, ev_args, ctx) | Like :meth:`.ChildList.from_events`, but the object is appended to the
list associated with its tag in the dict. | 6.031914 | 5.250205 | 1.148891 |
with parent_ctx as ctx:
obj = cls.__new__(cls)
attrs = ev_args[2]
attr_map = cls.ATTR_MAP.copy()
for key, value in attrs.items():
try:
prop = attr_map.pop(key)
except KeyError:
if cls... | def parse_events(cls, ev_args, parent_ctx) | Create an instance of this class, using the events sent into this
function. `ev_args` must be the event arguments of the ``"start"``
event.
.. seealso::
You probably should not call this method directly, but instead use
:class:`XSOParser` with a :class:`SAXDriver`.
... | 3.006614 | 2.967309 | 1.013246 |
if cls.__subclasses__():
raise TypeError(
"register_child is forbidden on classes with subclasses"
" (subclasses: {})".format(
", ".join(map(str, cls.__subclasses__()))
))
if child_cls.TAG in cls.CHILD_MAP:
... | def register_child(cls, prop, child_cls) | Register a new :class:`XMLStreamClass` instance `child_cls` for a given
:class:`Child` descriptor `prop`.
.. warning::
This method cannot be used after a class has been derived from this
class. This is for consistency: the method modifies the bookkeeping
attributes of ... | 5.58797 | 5.673323 | 0.984955 |
dest = [("start", )+tuple(ev_args)]
result = yield from capture_events(
super().parse_events(ev_args, parent_ctx),
dest
)
result._set_captured_events(dest)
return result | def parse_events(cls, ev_args, parent_ctx) | Capture the events sent to :meth:`.XSO.parse_events`,
including the initial `ev_args` to a list and call
:meth:`_set_captured_events` on the result of
:meth:`.XSO.parse_events`.
Like the method it overrides, :meth:`parse_events` is suspendable. | 9.521303 | 6.530398 | 1.457997 |
if cls.TAG in self._tag_map:
raise ValueError(
"duplicate tag: {!r} is already handled by {}".format(
cls.TAG,
self._tag_map[cls.TAG]))
self._class_map[cls] = callback
self._tag_map[cls.TAG] = (cls, callback) | def add_class(self, cls, callback) | Add a class `cls` for parsing as root level element. When an object of
`cls` type has been completely parsed, `callback` is called with the
object as argument. | 3.35236 | 3.218288 | 1.041659 |
del self._tag_map[cls.TAG]
del self._class_map[cls] | def remove_class(self, cls) | Remove a XSO class `cls` from parsing. This method raises
:class:`KeyError` with the classes :attr:`TAG` attribute as argument if
removing fails because the class is not registered. | 6.877102 | 4.525895 | 1.519501 |
for c in chars:
if any(in_table(c) for in_table in tables):
return c
return None | def check_against_tables(chars, tables) | Perform a check against the table predicates in `tables`. `tables` must be
a reusable iterable containing characteristic functions of character sets,
that is, functions which return :data:`True` if the character is in the
table.
The function returns the first character occuring in any of the tables or
... | 4.827956 | 4.209559 | 1.146903 |
# the empty string is valid, as it cannot violate the RandALCat constraints
if not chars:
return
# first_is_RorAL = unicodedata.bidirectional(chars[0]) in {"R", "AL"}
# if first_is_RorAL:
has_RandALCat = any(is_RandALCat(c) for c in chars)
if not has_RandALCat:
return
... | def check_bidi(chars) | Check proper bidirectionality as per stringprep. Operates on a list of
unicode characters provided in `chars`. | 4.418962 | 4.396209 | 1.005176 |
violator = check_against_tables(chars, bad_tables)
if violator is not None:
raise ValueError("Input contains invalid unicode codepoint: "
"U+{:04x}".format(ord(violator))) | def check_prohibited_output(chars, bad_tables) | Check against prohibited output, by checking whether any of the characters
from `chars` are in any of the `bad_tables`.
Operates in-place on a list of code points from `chars`. | 5.337888 | 6.650119 | 0.802676 |
bad_tables = (
stringprep.in_table_a1,)
violator = check_against_tables(chars, bad_tables)
if violator is not None:
raise ValueError("Input contains unassigned code point: "
"U+{:04x}".format(ord(violator))) | def check_unassigned(chars, bad_tables) | Check that `chars` does not contain any unassigned code points as per
the given list of `bad_tables`.
Operates on a list of unicode code points provided in `chars`. | 7.614756 | 8.503756 | 0.895458 |
chars = list(string)
_nodeprep_do_mapping(chars)
do_normalization(chars)
check_prohibited_output(
chars,
(
stringprep.in_table_c11,
stringprep.in_table_c12,
stringprep.in_table_c21,
stringprep.in_table_c22,
stringprep.in_t... | def nodeprep(string, allow_unassigned=False) | Process the given `string` using the Nodeprep (`RFC 6122`_) profile. In the
error cases defined in `RFC 3454`_ (stringprep), a :class:`ValueError` is
raised. | 2.738091 | 2.673373 | 1.024208 |
chars = list(string)
_resourceprep_do_mapping(chars)
do_normalization(chars)
check_prohibited_output(
chars,
(
stringprep.in_table_c12,
stringprep.in_table_c21,
stringprep.in_table_c22,
stringprep.in_table_c3,
stringprep.i... | def resourceprep(string, allow_unassigned=False) | Process the given `string` using the Resourceprep (`RFC 6122`_) profile. In
the error cases defined in `RFC 3454`_ (stringprep), a :class:`ValueError`
is raised. | 2.720873 | 2.657094 | 1.024003 |
if mime_type == "image/png":
if image_bytes is not None:
if self._image_bytes is not None:
raise RuntimeError(
"Only one avatar image may be published directly."
)
sha1 = hashlib.sha1()
... | def add_avatar_image(self, mime_type, *, id_=None,
image_bytes=None, width=None, height=None,
url=None, nbytes=None) | Add a source of the avatar image.
All sources of an avatar image added to an avatar set must be
*the same image*, in different formats and sizes.
:param mime_type: The MIME type of the avatar image.
:param id_: The SHA1 of the image data.
:param nbytes: The size of the image da... | 2.569891 | 2.451095 | 1.048466 |
if require_fresh:
self._metadata_cache.pop(jid, None)
else:
try:
return self._metadata_cache[jid]
except KeyError:
pass
if disable_pep:
metadata = []
else:
metadata = yield from self._g... | def get_avatar_metadata(self, jid, *, require_fresh=False,
disable_pep=False) | Retrieve a list of avatar descriptors.
:param jid: the JID for which to retrieve the avatar metadata.
:type jid: :class:`aioxmpp.JID`
:param require_fresh: if true, do not return results from the
avatar metadata chache, but retrieve them again from the server.
:type require_... | 5.062148 | 4.989407 | 1.014579 |
id_ = avatar_set.png_id
done = False
with (yield from self._publish_lock):
if (yield from self._pep.available()):
yield from self._pep.publish(
namespaces.xep0084_data,
avatar_xso.Data(avatar_set.image_bytes),
... | def publish_avatar_set(self, avatar_set) | Make `avatar_set` the current avatar of the jid associated with this
connection.
If :attr:`synchronize_vcard` is true and PEP is available the
vCard is only synchronized if the PEP update is successful.
This means publishing the ``image/png`` avatar data and the
avatar metadata... | 5.18503 | 4.215149 | 1.230094 |
with (yield from self._publish_lock):
todo = []
if self._synchronize_vcard:
todo.append(self._disable_vcard_avatar())
if (yield from self._pep.available()):
todo.append(self._pep.publish(
namespaces.xep0084_metada... | def disable_avatar(self) | Temporarily disable the avatar.
If :attr:`synchronize_vcard` is true, the vCard avatar is
disabled (even if disabling the PEP avatar fails).
This is done by setting the avatar metadata node empty and if
:attr:`synchronize_vcard` is true, downloading the vCard,
removing the avat... | 15.547877 | 10.061385 | 1.545302 |
@asyncio.coroutine
def _wipe_pep_avatar():
yield from self._pep.publish(
namespaces.xep0084_metadata,
avatar_xso.Metadata()
)
yield from self._pep.publish(
namespaces.xep0084_data,
avatar_xso.Da... | def wipe_avatar(self) | Remove all avatar data stored on the server.
If :attr:`synchronize_vcard` is true, the vCard avatar is
disabled even if disabling the PEP avatar fails.
This is equivalent to :meth:`disable_avatar` for vCard-based
avatars, but will also remove the data PubSub node for
PEP avatar... | 7.636015 | 5.264443 | 1.450489 |
yield from self._check_for_blocking()
if not jids_to_block:
return
cmd = blocking_xso.BlockCommand(jids_to_block)
iq = aioxmpp.IQ(
type_=aioxmpp.IQType.SET,
payload=cmd,
)
yield from self.client.send(iq) | def block_jids(self, jids_to_block) | Add the JIDs in the sequence `jids_to_block` to the client's
blocklist. | 6.236922 | 6.317786 | 0.987201 |
yield from self._check_for_blocking()
if not jids_to_unblock:
return
cmd = blocking_xso.UnblockCommand(jids_to_unblock)
iq = aioxmpp.IQ(
type_=aioxmpp.IQType.SET,
payload=cmd,
)
yield from self.client.send(iq) | def unblock_jids(self, jids_to_unblock) | Remove the JIDs in the sequence `jids_to_block` from the
client's blocklist. | 5.927799 | 6.08243 | 0.974577 |
if descriptor.root_class is not self or self.__subclasses__():
raise TypeError(
"descriptors cannot be modified on classes with subclasses"
)
meta = type(self)
descriptor_info = meta._upcast_descriptor_map(
self.DESCRIPTOR_MAP,
... | def _register_descriptor_keys(self, descriptor, keys) | Register the given descriptor keys for the given descriptor at the
class.
:param descriptor: The descriptor for which the `keys` shall be
registered.
:type descriptor: :class:`AbstractDescriptor` instance
:param keys: An iterable of descriptor keys
:ra... | 7.011401 | 6.274813 | 1.117388 |
my_form_type = getattr(self, "FORM_TYPE", None)
f = self()
for field in xso.fields:
if field.var == "FORM_TYPE":
if (my_form_type is not None and
field.type_ == forms_xso.FieldType.HIDDEN and
field.values):
... | def from_xso(self, xso) | Construct and return an instance from the given `xso`.
.. note::
This is a static method (classmethod), even though sphinx does not
document it as such.
:param xso: A :xep:`4` data form
:type xso: :class:`~.Data`
:raises ValueError: if the ``FORM_TYPE`` mismatche... | 3.647419 | 3.100134 | 1.176536 |
data = copy.copy(self._recv_xso)
data.type_ = forms_xso.DataType.SUBMIT
data.fields = list(self._recv_xso.fields)
for i, field_xso in enumerate(data.fields):
if field_xso.var is None:
continue
if field_xso.var == "FORM_TYPE":
... | def render_reply(self) | Create a :class:`~.Data` object equal to the object from which the from
was created through :meth:`from_xso`, except that the values of the
fields are exchanged with the values set on the form.
Fields which have no corresponding form descriptor are left untouched.
Fields which are acces... | 5.879687 | 4.408779 | 1.333632 |
data = forms_xso.Data(type_=forms_xso.DataType.FORM)
try:
layout = self.LAYOUT
except AttributeError:
layout = list(self.DESCRIPTORS)
my_form_type = getattr(self, "FORM_TYPE", None)
if my_form_type is not None:
field_xso = forms_xso... | def render_request(self) | Create a :class:`Data` object containing all fields known to the
:class:`Form`. If the :class:`Form` has a :attr:`LAYOUT` attribute, it
is used during generation. | 3.374109 | 3.03184 | 1.112891 |
try:
result = self.lookup_in_database(key)
except KeyError:
pass
else:
return result
while True:
fut = self._lookup_cache[key]
try:
result = yield from fut
except ValueError:
... | def lookup(self, key) | Look up the given `node` URL using the given `hash_` first in the
database and then by waiting on the futures created with
:meth:`create_query_future` for that node URL and hash.
If the hash is not in the database, :meth:`lookup` iterates as long as
there are pending futures for the giv... | 4.569356 | 3.467741 | 1.317675 |
fut = asyncio.Future()
fut.add_done_callback(
functools.partial(self._erase_future, key)
)
self._lookup_cache[key] = fut
return fut | def create_query_future(self, key) | Create and return a :class:`asyncio.Future` for the given `hash_`
function and `node` URL. The future is referenced internally and used
by any calls to :meth:`lookup` which are made while the future is
pending. The future is removed from the internal storage automatically
when a result o... | 3.988406 | 4.323087 | 0.922583 |
copied_entry = copy.copy(entry)
self._memory_overlay[key] = copied_entry
if self._user_db_path is not None:
asyncio.ensure_future(asyncio.get_event_loop().run_in_executor(
None,
writeback,
self._user_db_path / key.path,
... | def add_cache_entry(self, key, entry) | Add the given `entry` (which must be a :class:`~.disco.xso.InfoQuery`
instance) to the user-level database keyed with the hash function type
`hash_` and the `node` URL. The `entry` is **not** validated to
actually map to `node` with the given `hash_` function, it is expected
that the cal... | 6.202803 | 6.0534 | 1.024681 |
if node_namespace in self._pep_node_claims:
raise RuntimeError(
"claiming already claimed node"
)
registered_node = RegisteredPEPNode(
self,
node_namespace,
register_feature=register_feature,
notify=notify,
... | def claim_pep_node(self, node_namespace, *,
register_feature=True, notify=False) | Claim node `node_namespace`.
:param node_namespace: the pubsub node whose events shall be
handled.
:param register_feature: Whether to publish the `node_namespace`
as feature.
:param notify: Whether to register the ``+notify`` feature to
receive notification ... | 4.735201 | 4.468795 | 1.059615 |
disco_info = yield from self._disco_client.query_info(
self.client.local_jid.bare()
)
for item in disco_info.identities.filter(attrs={"category": "pubsub"}):
if item.type_ == "pep":
return True
return False | def available(self) | Check whether we have a PEP identity associated with our account. | 9.911722 | 7.84935 | 1.262744 |
publish_options = None
def autocreate_publish_options():
nonlocal publish_options
if publish_options is None:
publish_options = aioxmpp.forms.Data(
aioxmpp.forms.DataType.SUBMIT
)
publish_options.fields... | def publish(self, node, data, *, id_=None, access_model=None) | Publish an item `data` in the PubSub node `node` on the
PEP service associated with the user's JID.
:param node: The PubSub node to publish to.
:param data: The item to publish.
:type data: An XSO representing the paylaod.
:param id_: The id the published item shall have.
... | 3.279744 | 3.235919 | 1.013543 |
if self._closed:
return
self._closed = True
self._pep_service._unclaim(self.node_namespace)
self._unregister() | def close(self) | Unclaim the PEP node and unregister the registered features.
It is not necessary to call close if this claim is managed by
:class:`~aioxmpp.pep.register_pep_node`. | 16.228786 | 7.672322 | 2.115238 |
# validate against neomodel
try:
self.deflate(self.__properties__, self)
except DeflateError as e:
raise ValidationError({e.property_name: e.msg})
except RequiredProperty as e:
raise ValidationError({e.property_name: 'is required'}) | def full_clean(self, exclude, validate_unique=False) | Validate node, on error raising ValidationErrors which can be handled by django forms
:param exclude:
:param validate_unique: Check if conflicting node exists in the labels indexes
:return: | 7.698587 | 8.064616 | 0.954613 |
send_mail(subject, message, from_email, [self.email]) | def email_user(self, subject, message, from_email=None) | Send an email to this User. | 2.555168 | 2.494806 | 1.024195 |
n = 0
for user in queryset:
if not user.is_active:
user.activate()
n += 1
self.message_user(
request,
_('Successfully activated %(count)d %(items)s.') %
{'count': n, 'items': model_ngettext(self.opts, n)}, ... | def activate_users(self, request, queryset) | Activates the selected users, if they are not already
activated. | 2.596697 | 2.518561 | 1.031024 |
n = 0
for user in queryset:
if not user.is_active and settings.USERS_VERIFY_EMAIL:
send_activation_email(user=user, request=request)
n += 1
self.message_user(
request, _('Activation emails sent to %(count)d %(items)s.') %
... | def send_activation_email(self, request, queryset) | Send activation emails for the selected users, if they are not already
activated. | 3.084356 | 2.897843 | 1.064363 |
try:
qs = super(UserManager, self).get_queryset()
except AttributeError: # pragma: no cover
qs = super(UserManager, self).get_query_set()
return qs | def get_queryset(self) | Fixes get_query_set vs get_queryset for Django <1.6 | 2.80292 | 2.201268 | 1.27332 |
try:
ready, _, _ = self.select.select([self.fileno], [], [],
POLL_TIMEOUT)
return bool(ready)
except self.select.error as why:
if why.args[0] != EINTR:
self._exceptions.append(AMQPConnectionError(wh... | def is_ready(self) | Is Socket Ready.
:rtype: tuple | 5.079247 | 4.936975 | 1.028818 |
self._wr_lock.acquire()
self._rd_lock.acquire()
try:
self._running.clear()
if self.socket:
self._close_socket()
if self._inbound_thread:
self._inbound_thread.join(timeout=self._parameters['timeout'])
self._i... | def close(self) | Close Socket.
:return: | 3.294316 | 3.288371 | 1.001808 |
self._wr_lock.acquire()
self._rd_lock.acquire()
try:
self.data_in = EMPTY_BUFFER
self._running.set()
sock_addresses = self._get_socket_addresses()
self.socket = self._find_address_and_connect(sock_addresses)
self.poller = Polle... | def open(self) | Open Socket and establish a connection.
:raises AMQPConnectionError: Raises if the connection
encountered an error.
:return: | 4.592281 | 4.412899 | 1.04065 |
self._wr_lock.acquire()
try:
total_bytes_written = 0
bytes_to_send = len(frame_data)
while total_bytes_written < bytes_to_send:
try:
if not self.socket:
raise socket.error('connection/socket error')
... | def write_to_socket(self, frame_data) | Write data to the socket.
:param str frame_data:
:return: | 2.467165 | 2.523484 | 0.977682 |
try:
self.socket.shutdown(socket.SHUT_RDWR)
except (OSError, socket.error):
pass
self.socket.close() | def _close_socket(self) | Shutdown and close the Socket.
:return: | 2.505672 | 3.222481 | 0.77756 |
family = socket.AF_UNSPEC
if not socket.has_ipv6:
family = socket.AF_INET
try:
addresses = socket.getaddrinfo(self._parameters['hostname'],
self._parameters['port'], family,
soc... | def _get_socket_addresses(self) | Get Socket address information.
:rtype: list | 3.159858 | 3.618511 | 0.873248 |
error_message = None
for address in addresses:
sock = self._create_socket(socket_family=address[0])
try:
sock.connect(address[4])
except (IOError, OSError) as why:
error_message = why.strerror
continue
... | def _find_address_and_connect(self, addresses) | Find and connect to the appropriate address.
:param addresses:
:raises AMQPConnectionError: Raises if the connection
encountered an error.
:rtype: socket.socket | 3.677111 | 3.582413 | 1.026434 |
sock = socket.socket(socket_family, socket.SOCK_STREAM, 0)
sock.settimeout(self._parameters['timeout'] or None)
if self.use_ssl:
if not compatibility.SSL_SUPPORTED:
raise AMQPConnectionError(
'Python not compiled with support for TLSv1 or ... | def _create_socket(self, socket_family) | Create Socket.
:param int socket_family:
:rtype: socket.socket | 4.585487 | 4.992661 | 0.918445 |
context = self._parameters['ssl_options'].get('context')
if context is not None:
hostname = self._parameters['ssl_options'].get('server_hostname')
return context.wrap_socket(
sock, do_handshake_on_connect=True,
server_hostname=hostname
... | def _ssl_wrap_socket(self, sock) | Wrap SSLSocket around the Socket.
:param socket.socket sock:
:rtype: SSLSocket | 2.316607 | 2.434252 | 0.951671 |
inbound_thread = threading.Thread(target=self._process_incoming_data,
name=__name__)
inbound_thread.daemon = True
inbound_thread.start()
return inbound_thread | def _create_inbound_thread(self) | Internal Thread that handles all incoming traffic.
:rtype: threading.Thread | 3.161567 | 3.28877 | 0.961322 |
while self._running.is_set():
if self.poller.is_ready:
self.data_in += self._receive()
self.data_in = self._on_read_impl(self.data_in) | def _process_incoming_data(self) | Retrieve and process any incoming data.
:return: | 7.984606 | 8.428329 | 0.947353 |
data_in = EMPTY_BUFFER
try:
data_in = self._read_from_socket()
except socket.timeout:
pass
except (IOError, OSError) as why:
if why.args[0] not in (EWOULDBLOCK, EAGAIN):
self._exceptions.append(AMQPConnectionError(why))
... | def _receive(self) | Receive any incoming socket data.
If an error is thrown, handle it and return an empty string.
:return: data_in
:rtype: bytes | 4.241589 | 4.210531 | 1.007376 |
if not self.use_ssl:
if not self.socket:
raise socket.error('connection/socket error')
return self.socket.recv(MAX_FRAME_SIZE)
with self._rd_lock:
if not self.socket:
raise socket.error('connection/socket error')
r... | def _read_from_socket(self) | Read data from the socket.
:rtype: bytes | 3.542485 | 3.471297 | 1.020508 |
if not self._interval:
return False
self._running.set()
with self._lock:
self._threshold = 0
self._reads_since_check = 0
self._writes_since_check = 0
self._exceptions = exceptions
LOGGER.debug('Heartbeat Checker Started')
... | def start(self, exceptions) | Start the Heartbeat Checker.
:param list exceptions:
:return: | 6.210983 | 5.712902 | 1.087185 |
self._running.clear()
with self._lock:
if self._timer:
self._timer.cancel()
self._timer = None | def stop(self) | Stop the Heartbeat Checker.
:return: | 3.910264 | 4.606174 | 0.848918 |
if not self._running.is_set():
return False
if self._writes_since_check == 0:
self.send_heartbeat_impl()
self._lock.acquire()
try:
if self._reads_since_check == 0:
self._threshold += 1
if self._threshold >= 2:
... | def _check_for_life_signs(self) | Check Connection for life signs.
First check if any data has been sent, if not send a heartbeat
to the remote server.
If we have not received any data what so ever within two
intervals, we need to raise an exception so that we can
close the connection.
... | 4.179149 | 3.61602 | 1.155732 |
message = (
'Connection dead, no heartbeat or data received in >= '
'%ds' % (
self._interval * 2
)
)
why = AMQPConnectionError(message)
if self._exceptions is None:
raise why
self._exceptions.append(why) | def _raise_or_append_exception(self) | The connection is presumably dead and we need to raise or
append an exception.
If we have a list for exceptions, append the exception and let
the connection handle it, if not raise the exception here.
:return: | 9.912939 | 8.606533 | 1.151792 |
if not self._running.is_set():
return False
self._timer = self.timer_impl(
interval=self._interval,
function=self._check_for_life_signs
)
self._timer.daemon = True
self._timer.start()
return True | def _start_new_timer(self) | Create a timer that will be used to periodically check the
connection for heartbeats.
:return: | 4.911111 | 5.016604 | 0.978971 |
if not compatibility.is_string(exchange):
raise AMQPInvalidArgument('exchange should be a string')
elif not compatibility.is_string(exchange_type):
raise AMQPInvalidArgument('exchange_type should be a string')
elif not isinstance(passive, bool):
raise... | def declare(self, exchange='', exchange_type='direct', passive=False,
durable=False, auto_delete=False, arguments=None) | Declare an Exchange.
:param str exchange: Exchange name
:param str exchange_type: Exchange type
:param bool passive: Do not create
:param bool durable: Durable exchange
:param bool auto_delete: Automatically delete when not in use
:param dict arguments: Exchange key/valu... | 1.749635 | 1.791847 | 0.976442 |
if not compatibility.is_string(exchange):
raise AMQPInvalidArgument('exchange should be a string')
delete_frame = pamqp_exchange.Delete(exchange=exchange,
if_unused=if_unused)
return self._channel.rpc_request(delete_frame) | def delete(self, exchange='', if_unused=False) | Delete an Exchange.
:param str exchange: Exchange name
:param bool if_unused: Delete only if unused
:raises AMQPInvalidArgument: Invalid Parameters
:raises AMQPChannelError: Raises if the channel encountered an error.
:raises AMQPConnectionError: Raises if the connection
... | 5.400298 | 5.594097 | 0.965356 |
if not compatibility.is_string(destination):
raise AMQPInvalidArgument('destination should be a string')
elif not compatibility.is_string(source):
raise AMQPInvalidArgument('source should be a string')
elif not compatibility.is_string(routing_key):
ra... | def bind(self, destination='', source='', routing_key='',
arguments=None) | Bind an Exchange.
:param str destination: Exchange name
:param str source: Exchange to bind to
:param str routing_key: The routing key to use
:param dict arguments: Bind key/value arguments
:raises AMQPInvalidArgument: Invalid Parameters
:raises AMQPChannelError: Raises... | 2.157025 | 2.240693 | 0.962659 |
if not compatibility.is_string(destination):
raise AMQPInvalidArgument('destination should be a string')
elif not compatibility.is_string(source):
raise AMQPInvalidArgument('source should be a string')
elif not compatibility.is_string(routing_key):
ra... | def unbind(self, destination='', source='', routing_key='',
arguments=None) | Unbind an Exchange.
:param str destination: Exchange name
:param str source: Exchange to unbind from
:param str routing_key: The routing key used
:param dict arguments: Unbind key/value arguments
:raises AMQPInvalidArgument: Invalid Parameters
:raises AMQPChannelError: ... | 2.145588 | 2.198849 | 0.975778 |
virtual_host = quote(virtual_host, '')
return self.http_client.get(
API_QUEUE % (
virtual_host,
queue
)
) | def get(self, queue, virtual_host='/') | Get Queue details.
:param queue: Queue name
:param str virtual_host: Virtual host name
:raises ApiError: Raises if the remote server encountered an error.
:raises ApiConnectionError: Raises if there was a connectivity issue.
:rtype: dict | 5.409891 | 8.153623 | 0.663495 |
if show_all:
return self.http_client.get(API_QUEUES)
virtual_host = quote(virtual_host, '')
return self.http_client.get(
API_QUEUES_VIRTUAL_HOST % virtual_host
) | def list(self, virtual_host='/', show_all=False) | List Queues.
:param str virtual_host: Virtual host name
:param bool show_all: List all Queues
:raises ApiError: Raises if the remote server encountered an error.
:raises ApiConnectionError: Raises if there was a connectivity issue.
:rtype: list | 3.835666 | 4.882979 | 0.785517 |
if passive:
return self.get(queue, virtual_host=virtual_host)
queue_payload = json.dumps(
{
'durable': durable,
'auto_delete': auto_delete,
'arguments': arguments or {},
'vhost': virtual_host
}
... | def declare(self, queue='', virtual_host='/', passive=False, durable=False,
auto_delete=False, arguments=None) | Declare a Queue.
:param str queue: Queue name
:param str virtual_host: Virtual host name
:param bool passive: Do not create
:param bool durable: Durable queue
:param bool auto_delete: Automatically delete when not in use
:param dict|None arguments: Queue key/value argume... | 3.498232 | 3.701629 | 0.945052 |
virtual_host = quote(virtual_host, '')
return self.http_client.delete(API_QUEUE %
(
virtual_host,
queue
)) | def delete(self, queue, virtual_host='/') | Delete a Queue.
:param str queue: Queue name
:param str virtual_host: Virtual host name
:raises ApiError: Raises if the remote server encountered an error.
:raises ApiConnectionError: Raises if there was a connectivity issue.
:rtype: dict | 7.650171 | 11.634325 | 0.657552 |
virtual_host = quote(virtual_host, '')
return self.http_client.delete(API_QUEUE_PURGE %
(
virtual_host,
queue
)) | def purge(self, queue, virtual_host='/') | Purge a Queue.
:param str queue: Queue name
:param str virtual_host: Virtual host name
:raises ApiError: Raises if the remote server encountered an error.
:raises ApiConnectionError: Raises if there was a connectivity issue.
:rtype: None | 6.724941 | 9.330789 | 0.720726 |
virtual_host = quote(virtual_host, '')
return self.http_client.get(API_QUEUE_BINDINGS %
(
virtual_host,
queue
)) | def bindings(self, queue, virtual_host='/') | Get Queue bindings.
:param str queue: Queue name
:param str virtual_host: Virtual host name
:raises ApiError: Raises if the remote server encountered an error.
:raises ApiConnectionError: Raises if there was a connectivity issue.
:rtype: list | 7.311872 | 9.107108 | 0.802875 |
bind_payload = json.dumps({
'destination': queue,
'destination_type': 'q',
'routing_key': routing_key,
'source': exchange,
'arguments': arguments or {},
'vhost': virtual_host
})
virtual_host = quote(virtual_host, ''... | def bind(self, queue='', exchange='', routing_key='', virtual_host='/',
arguments=None) | Bind a Queue.
:param str queue: Queue name
:param str exchange: Exchange name
:param str routing_key: The routing key to use
:param str virtual_host: Virtual host name
:param dict|None arguments: Bind key/value arguments
:raises ApiError: Raises if the remote server enc... | 3.560263 | 4.026745 | 0.884154 |
unbind_payload = json.dumps({
'destination': queue,
'destination_type': 'q',
'properties_key': properties_key or routing_key,
'source': exchange,
'vhost': virtual_host
})
virtual_host = quote(virtual_host, '')
return se... | def unbind(self, queue='', exchange='', routing_key='', virtual_host='/',
properties_key=None) | Unbind a Queue.
:param str queue: Queue name
:param str exchange: Exchange name
:param str routing_key: The routing key to use
:param str virtual_host: Virtual host name
:param str properties_key:
:raises ApiError: Raises if the remote server encountered an error.
... | 3.601259 | 4.050325 | 0.889128 |
virtual_host = quote(virtual_host, '')
return self.http_client.get(
API_EXCHANGE
% (
virtual_host,
exchange)
) | def get(self, exchange, virtual_host='/') | Get Exchange details.
:param str exchange: Exchange name
:param str virtual_host: Virtual host name
:raises ApiError: Raises if the remote server encountered an error.
:raises ApiConnectionError: Raises if there was a connectivity issue.
:rtype: dict | 7.385724 | 9.431609 | 0.783082 |
if show_all:
return self.http_client.get(API_EXCHANGES)
virtual_host = quote(virtual_host, '')
return self.http_client.get(
API_EXCHANGES_VIRTUAL_HOST % virtual_host
) | def list(self, virtual_host='/', show_all=False) | List Exchanges.
:param str virtual_host: Virtual host name
:param bool show_all: List all Exchanges
:raises ApiError: Raises if the remote server encountered an error.
:raises ApiConnectionError: Raises if there was a connectivity issue.
:rtype: list | 3.8307 | 4.737185 | 0.808645 |
if passive:
return self.get(exchange, virtual_host=virtual_host)
exchange_payload = json.dumps(
{
'durable': durable,
'auto_delete': auto_delete,
'internal': internal,
'type': exchange_type,
... | def declare(self, exchange='', exchange_type='direct', virtual_host='/',
passive=False, durable=False, auto_delete=False,
internal=False, arguments=None) | Declare an Exchange.
:param str exchange: Exchange name
:param str exchange_type: Exchange type
:param str virtual_host: Virtual host name
:param bool passive: Do not create
:param bool durable: Durable exchange
:param bool auto_delete: Automatically delete when not in u... | 3.487544 | 3.399412 | 1.025926 |
virtual_host = quote(virtual_host, '')
return self.http_client.delete(API_EXCHANGE %
(
virtual_host,
exchange
)) | def delete(self, exchange, virtual_host='/') | Delete an Exchange.
:param str exchange: Exchange name
:param str virtual_host: Virtual host name
:raises ApiError: Raises if the remote server encountered an error.
:raises ApiConnectionError: Raises if there was a connectivity issue.
:rtype: dict | 8.068014 | 10.852618 | 0.743416 |
virtual_host = quote(virtual_host, '')
return self.http_client.get(API_EXCHANGE_BINDINGS %
(
virtual_host,
exchange
)) | def bindings(self, exchange, virtual_host='/') | Get Exchange bindings.
:param str exchange: Exchange name
:param str virtual_host: Virtual host name
:raises ApiError: Raises if the remote server encountered an error.
:raises ApiConnectionError: Raises if there was a connectivity issue.
:rtype: list | 7.124067 | 8.796122 | 0.80991 |
bind_payload = json.dumps({
'destination': destination,
'destination_type': 'e',
'routing_key': routing_key,
'source': source,
'arguments': arguments or {},
'vhost': virtual_host
})
virtual_host = quote(virtual_host... | def bind(self, destination='', source='', routing_key='', virtual_host='/',
arguments=None) | Bind an Exchange.
:param str source: Source Exchange name
:param str destination: Destination Exchange name
:param str routing_key: The routing key to use
:param str virtual_host: Virtual host name
:param dict|None arguments: Bind key/value arguments
:raises ApiError: R... | 3.543997 | 3.700279 | 0.957765 |
unbind_payload = json.dumps({
'destination': destination,
'destination_type': 'e',
'properties_key': properties_key or routing_key,
'source': source,
'vhost': virtual_host
})
virtual_host = quote(virtual_host, '')
retur... | def unbind(self, destination='', source='', routing_key='',
virtual_host='/', properties_key=None) | Unbind an Exchange.
:param str source: Source Exchange name
:param str destination: Destination Exchange name
:param str routing_key: The routing key to use
:param str virtual_host: Virtual host name
:param str properties_key:
:raises ApiError: Raises if the remote serv... | 3.521569 | 3.624768 | 0.971529 |
LOGGER.debug('Opening a new Channel')
if not compatibility.is_integer(rpc_timeout):
raise AMQPInvalidArgument('rpc_timeout should be an integer')
elif self.is_closed:
raise AMQPConnectionError('socket/connection closed')
with self.lock:
chann... | def channel(self, rpc_timeout=60, lazy=False) | Open Channel.
:param int rpc_timeout: Timeout before we give up waiting for an RPC
response from the server.
:raises AMQPInvalidArgument: Invalid Parameters
:raises AMQPChannelError: Raises if the channel encountered an error.
:raises AMQPConnectionError... | 3.907703 | 3.575563 | 1.092892 |
if not self.exceptions:
if not self.is_closed:
return
why = AMQPConnectionError('connection was closed')
self.exceptions.append(why)
self.set_state(self.CLOSED)
self.close()
raise self.exceptions[0] | def check_for_errors(self) | Check Connection for errors.
:raises AMQPConnectionError: Raises if the connection
encountered an error.
:return: | 6.384198 | 5.552339 | 1.149821 |
LOGGER.debug('Connection Closing')
if not self.is_closed:
self.set_state(self.CLOSING)
self.heartbeat.stop()
try:
if not self.is_closed and self.socket:
self._channel0.send_close_connection()
self._wait_for_connection_state... | def close(self) | Close connection.
:raises AMQPConnectionError: Raises if the connection
encountered an error.
:return: | 5.199408 | 4.980036 | 1.04405 |
LOGGER.debug('Connection Opening')
self.set_state(self.OPENING)
self._exceptions = []
self._channels = {}
self._last_channel_id = None
self._io.open()
self._send_handshake()
self._wait_for_connection_state(state=Stateful.OPEN)
self.heartbe... | def open(self) | Open Connection.
:raises AMQPConnectionError: Raises if the connection
encountered an error. | 6.452983 | 6.081353 | 1.06111 |
frame_data = pamqp_frame.marshal(frame_out, channel_id)
self.heartbeat.register_write()
self._io.write_to_socket(frame_data) | def write_frame(self, channel_id, frame_out) | Marshal and write an outgoing pamqp frame to the Socket.
:param int channel_id: Channel ID.
:param specification.Frame frame_out: Amqp frame.
:return: | 8.644195 | 8.910188 | 0.970147 |
data_out = EMPTY_BUFFER
for single_frame in frames_out:
data_out += pamqp_frame.marshal(single_frame, channel_id)
self.heartbeat.register_write()
self._io.write_to_socket(data_out) | def write_frames(self, channel_id, frames_out) | Marshal and write multiple outgoing pamqp frames to the Socket.
:param int channel_id: Channel ID/
:param list frames_out: Amqp frames.
:return: | 7.245027 | 6.992193 | 1.03616 |
for channel_id in list(self._channels):
self._channels[channel_id].set_state(Channel.CLOSED)
self._channels[channel_id].close()
self._cleanup_channel(channel_id) | def _close_remaining_channels(self) | Forcefully close all open channels.
:return: | 3.298438 | 3.823617 | 0.862649 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.