id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
51
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
800
horazont/aioxmpp
aioxmpp/pubsub/service.py
PubSubClient.retract
def retract(self, jid, node, id_, *, notify=False): """ Retract a previously published item from a node. :param jid: Address of the PubSub service. :type jid: :class:`aioxmpp.JID` :param node: Name of the PubSub node to send a notify from. :type node: :class:`str` ...
python
def retract(self, jid, node, id_, *, notify=False): retract = pubsub_xso.Retract() retract.node = node item = pubsub_xso.Item() item.id_ = id_ retract.item = item retract.notify = notify iq = aioxmpp.stanza.IQ(to=jid, type_=aioxmpp.structs.IQType.SET) iq....
[ "def", "retract", "(", "self", ",", "jid", ",", "node", ",", "id_", ",", "*", ",", "notify", "=", "False", ")", ":", "retract", "=", "pubsub_xso", ".", "Retract", "(", ")", "retract", ".", "node", "=", "node", "item", "=", "pubsub_xso", ".", "Item"...
Retract a previously published item from a node. :param jid: Address of the PubSub service. :type jid: :class:`aioxmpp.JID` :param node: Name of the PubSub node to send a notify from. :type node: :class:`str` :param id_: The ID of the item to retract. :type id_: :class:`...
[ "Retract", "a", "previously", "published", "item", "from", "a", "node", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/pubsub/service.py#L749-L782
801
horazont/aioxmpp
aioxmpp/pubsub/service.py
PubSubClient.create
def create(self, jid, node=None): """ Create a new node at a service. :param jid: Address of the PubSub service. :type jid: :class:`aioxmpp.JID` :param node: Name of the PubSub node to create. :type node: :class:`str` or :data:`None` :raises aioxmpp.errors.XMPPEr...
python
def create(self, jid, node=None): create = pubsub_xso.Create() create.node = node iq = aioxmpp.stanza.IQ( type_=aioxmpp.structs.IQType.SET, to=jid, payload=pubsub_xso.Request(create) ) response = yield from self.client.send(iq) if re...
[ "def", "create", "(", "self", ",", "jid", ",", "node", "=", "None", ")", ":", "create", "=", "pubsub_xso", ".", "Create", "(", ")", "create", ".", "node", "=", "node", "iq", "=", "aioxmpp", ".", "stanza", ".", "IQ", "(", "type_", "=", "aioxmpp", ...
Create a new node at a service. :param jid: Address of the PubSub service. :type jid: :class:`aioxmpp.JID` :param node: Name of the PubSub node to create. :type node: :class:`str` or :data:`None` :raises aioxmpp.errors.XMPPError: as returned by the service :return: The n...
[ "Create", "a", "new", "node", "at", "a", "service", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/pubsub/service.py#L785-L817
802
horazont/aioxmpp
aioxmpp/pubsub/service.py
PubSubClient.delete
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...
python
def delete(self, jid, node, *, redirect_uri=None): iq = aioxmpp.stanza.IQ( type_=aioxmpp.structs.IQType.SET, to=jid, payload=pubsub_xso.OwnerRequest( pubsub_xso.OwnerDelete( node, redirect_uri=redirect_uri ...
[ "def", "delete", "(", "self", ",", "jid", ",", "node", ",", "*", ",", "redirect_uri", "=", "None", ")", ":", "iq", "=", "aioxmpp", ".", "stanza", ".", "IQ", "(", "type_", "=", "aioxmpp", ".", "structs", ".", "IQType", ".", "SET", ",", "to", "=", ...
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...
[ "Delete", "an", "existing", "node", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/pubsub/service.py#L820-L849
803
horazont/aioxmpp
aioxmpp/pubsub/service.py
PubSubClient.get_nodes
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` :rais...
python
def get_nodes(self, jid, node=None): 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, ...
[ "def", "get_nodes", "(", "self", ",", "jid", ",", "node", "=", "None", ")", ":", "response", "=", "yield", "from", "self", ".", "_disco", ".", "query_items", "(", "jid", ",", "node", "=", "node", ",", ")", "result", "=", "[", "]", "for", "item", ...
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 ...
[ "Request", "all", "nodes", "at", "a", "service", "or", "collection", "node", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/pubsub/service.py#L852-L891
804
horazont/aioxmpp
aioxmpp/pubsub/service.py
PubSubClient.get_node_affiliations
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.XMPP...
python
def get_node_affiliations(self, jid, node): 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", ")", ":", "iq", "=", "aioxmpp", ".", "stanza", ".", "IQ", "(", "type_", "=", "aioxmpp", ".", "structs", ".", "IQType", ".", "GET", ",", "to", "=", "jid", ",", "payload", "=", "pu...
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 ...
[ "Return", "the", "affiliations", "of", "other", "jids", "at", "a", "node", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/pubsub/service.py#L894-L918
805
horazont/aioxmpp
aioxmpp/pubsub/service.py
PubSubClient.change_node_affiliations
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 affiliati...
python
def change_node_affiliations(self, jid, node, affiliations_to_set): iq = aioxmpp.stanza.IQ( type_=aioxmpp.structs.IQType.SET, to=jid, payload=pubsub_xso.OwnerRequest( pubsub_xso.OwnerAffiliations( node, affiliations=[ ...
[ "def", "change_node_affiliations", "(", "self", ",", "jid", ",", "node", ",", "affiliations_to_set", ")", ":", "iq", "=", "aioxmpp", ".", "stanza", ".", "IQ", "(", "type_", "=", "aioxmpp", ".", "structs", ".", "IQType", ".", "SET", ",", "to", "=", "jid...
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...
[ "Update", "the", "affiliations", "at", "a", "node", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/pubsub/service.py#L948-L982
806
horazont/aioxmpp
aioxmpp/pubsub/service.py
PubSubClient.change_node_subscriptions
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 subscr...
python
def change_node_subscriptions(self, jid, node, subscriptions_to_set): iq = aioxmpp.stanza.IQ( type_=aioxmpp.structs.IQType.SET, to=jid, payload=pubsub_xso.OwnerRequest( pubsub_xso.OwnerSubscriptions( node, subscriptions=...
[ "def", "change_node_subscriptions", "(", "self", ",", "jid", ",", "node", ",", "subscriptions_to_set", ")", ":", "iq", "=", "aioxmpp", ".", "stanza", ".", "IQ", "(", "type_", "=", "aioxmpp", ".", "structs", ".", "IQType", ".", "SET", ",", "to", "=", "j...
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: ...
[ "Update", "the", "subscriptions", "at", "a", "node", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/pubsub/service.py#L985-L1020
807
horazont/aioxmpp
aioxmpp/pubsub/service.py
PubSubClient.purge
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`. """ iq = aioxmpp.stanza.IQ( type_=aioxmpp....
python
def purge(self, jid, node): 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", ")", ":", "iq", "=", "aioxmpp", ".", "stanza", ".", "IQ", "(", "type_", "=", "aioxmpp", ".", "structs", ".", "IQType", ".", "SET", ",", "to", "=", "jid", ",", "payload", "=", "pubsub_xso", "."...
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`.
[ "Delete", "all", "items", "from", "a", "node", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/pubsub/service.py#L1023-L1044
808
horazont/aioxmpp
aioxmpp/xso/model.py
Child.from_events
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. """ obj = yiel...
python
def from_events(self, instance, ev_args, ctx): obj = yield from self._process(instance, ev_args, ctx) self.__set__(instance, obj) return obj
[ "def", "from_events", "(", "self", ",", "instance", ",", "ev_args", ",", "ctx", ")", ":", "obj", "=", "yield", "from", "self", ".", "_process", "(", "instance", ",", "ev_args", ",", "ctx", ")", "self", ".", "__set__", "(", "instance", ",", "obj", ")"...
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.
[ "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", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/xso/model.py#L556-L566
809
horazont/aioxmpp
aioxmpp/xso/model.py
XSOParser.add_class
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. """ if cls.TAG in self._tag_map: raise ValueError( ...
python
def add_class(self, cls, callback): 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] =...
[ "def", "add_class", "(", "self", ",", "cls", ",", "callback", ")", ":", "if", "cls", ".", "TAG", "in", "self", ".", "_tag_map", ":", "raise", "ValueError", "(", "\"duplicate tag: {!r} is already handled by {}\"", ".", "format", "(", "cls", ".", "TAG", ",", ...
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.
[ "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", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/xso/model.py#L2496-L2508
810
horazont/aioxmpp
aioxmpp/stringprep.py
check_bidi
def check_bidi(chars): """ Check proper bidirectionality as per stringprep. Operates on a list of unicode characters provided in `chars`. """ # the empty string is valid, as it cannot violate the RandALCat constraints if not chars: return # first_is_RorAL = unicodedata.bidirectiona...
python
def check_bidi(chars): # 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: ...
[ "def", "check_bidi", "(", "chars", ")", ":", "# 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", "=", ...
Check proper bidirectionality as per stringprep. Operates on a list of unicode characters provided in `chars`.
[ "Check", "proper", "bidirectionality", "as", "per", "stringprep", ".", "Operates", "on", "a", "list", "of", "unicode", "characters", "provided", "in", "chars", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/stringprep.py#L81-L104
811
horazont/aioxmpp
aioxmpp/stringprep.py
check_prohibited_output
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`. """ violator = check_against_tables(chars, bad_tables) if viol...
python
def check_prohibited_output(chars, bad_tables): 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", ")", ":", "violator", "=", "check_against_tables", "(", "chars", ",", "bad_tables", ")", "if", "violator", "is", "not", "None", ":", "raise", "ValueError", "(", "\"Input contains invalid unicode code...
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`.
[ "Check", "against", "prohibited", "output", "by", "checking", "whether", "any", "of", "the", "characters", "from", "chars", "are", "in", "any", "of", "the", "bad_tables", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/stringprep.py#L107-L117
812
horazont/aioxmpp
aioxmpp/stringprep.py
check_unassigned
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`. """ bad_tables = ( stringprep.in_table_a1,) violator = check_against_tab...
python
def check_unassigned(chars, bad_tables): 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", ")", ":", "bad_tables", "=", "(", "stringprep", ".", "in_table_a1", ",", ")", "violator", "=", "check_against_tables", "(", "chars", ",", "bad_tables", ")", "if", "violator", "is", "not", "None", ":...
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`.
[ "Check", "that", "chars", "does", "not", "contain", "any", "unassigned", "code", "points", "as", "per", "the", "given", "list", "of", "bad_tables", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/stringprep.py#L120-L133
813
horazont/aioxmpp
aioxmpp/avatar/service.py
AvatarSet.add_avatar_image
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*, i...
python
def add_avatar_image(self, mime_type, *, id_=None, image_bytes=None, width=None, height=None, url=None, nbytes=None): if mime_type == "image/png": if image_bytes is not None: if self._image_bytes is not None: raise...
[ "def", "add_avatar_image", "(", "self", ",", "mime_type", ",", "*", ",", "id_", "=", "None", ",", "image_bytes", "=", "None", ",", "width", "=", "None", ",", "height", "=", "None", ",", "url", "=", "None", ",", "nbytes", "=", "None", ")", ":", "if"...
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...
[ "Add", "a", "source", "of", "the", "avatar", "image", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/avatar/service.py#L95-L183
814
horazont/aioxmpp
aioxmpp/avatar/service.py
AvatarService.get_avatar_metadata
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 ...
python
def get_avatar_metadata(self, jid, *, require_fresh=False, disable_pep=False): if require_fresh: self._metadata_cache.pop(jid, None) else: try: return self._metadata_cache[jid] except KeyError: pass ...
[ "def", "get_avatar_metadata", "(", "self", ",", "jid", ",", "*", ",", "require_fresh", "=", "False", ",", "disable_pep", "=", "False", ")", ":", "if", "require_fresh", ":", "self", ".", "_metadata_cache", ".", "pop", "(", "jid", ",", "None", ")", "else",...
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_...
[ "Retrieve", "a", "list", "of", "avatar", "descriptors", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/avatar/service.py#L835-L896
815
horazont/aioxmpp
aioxmpp/avatar/service.py
AvatarService.publish_avatar_set
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...
python
def publish_avatar_set(self, avatar_set): 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(...
[ "def", "publish_avatar_set", "(", "self", ",", "avatar_set", ")", ":", "id_", "=", "avatar_set", ".", "png_id", "done", "=", "False", "with", "(", "yield", "from", "self", ".", "_publish_lock", ")", ":", "if", "(", "yield", "from", "self", ".", "_pep", ...
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...
[ "Make", "avatar_set", "the", "current", "avatar", "of", "the", "jid", "associated", "with", "this", "connection", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/avatar/service.py#L913-L956
816
horazont/aioxmpp
aioxmpp/avatar/service.py
AvatarService.disable_avatar
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, do...
python
def disable_avatar(self): 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( namespace...
[ "def", "disable_avatar", "(", "self", ")", ":", "with", "(", "yield", "from", "self", ".", "_publish_lock", ")", ":", "todo", "=", "[", "]", "if", "self", ".", "_synchronize_vcard", ":", "todo", ".", "append", "(", "self", ".", "_disable_vcard_avatar", "...
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...
[ "Temporarily", "disable", "the", "avatar", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/avatar/service.py#L967-L995
817
horazont/aioxmpp
aioxmpp/avatar/service.py
AvatarService.wipe_avatar
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 ...
python
def wipe_avatar(self): @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, ...
[ "def", "wipe_avatar", "(", "self", ")", ":", "@", "asyncio", ".", "coroutine", "def", "_wipe_pep_avatar", "(", ")", ":", "yield", "from", "self", ".", "_pep", ".", "publish", "(", "namespaces", ".", "xep0084_metadata", ",", "avatar_xso", ".", "Metadata", "...
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...
[ "Remove", "all", "avatar", "data", "stored", "on", "the", "server", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/avatar/service.py#L998-L1034
818
horazont/aioxmpp
aioxmpp/blocking/service.py
BlockingClient.block_jids
def block_jids(self, jids_to_block): """ Add the JIDs in the sequence `jids_to_block` to the client's blocklist. """ yield from self._check_for_blocking() if not jids_to_block: return cmd = blocking_xso.BlockCommand(jids_to_block) iq = aioxmp...
python
def block_jids(self, jids_to_block): 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.se...
[ "def", "block_jids", "(", "self", ",", "jids_to_block", ")", ":", "yield", "from", "self", ".", "_check_for_blocking", "(", ")", "if", "not", "jids_to_block", ":", "return", "cmd", "=", "blocking_xso", ".", "BlockCommand", "(", "jids_to_block", ")", "iq", "=...
Add the JIDs in the sequence `jids_to_block` to the client's blocklist.
[ "Add", "the", "JIDs", "in", "the", "sequence", "jids_to_block", "to", "the", "client", "s", "blocklist", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/blocking/service.py#L134-L149
819
horazont/aioxmpp
aioxmpp/blocking/service.py
BlockingClient.unblock_jids
def unblock_jids(self, jids_to_unblock): """ Remove the JIDs in the sequence `jids_to_block` from the client's blocklist. """ yield from self._check_for_blocking() if not jids_to_unblock: return cmd = blocking_xso.UnblockCommand(jids_to_unblock) ...
python
def unblock_jids(self, jids_to_unblock): 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...
[ "def", "unblock_jids", "(", "self", ",", "jids_to_unblock", ")", ":", "yield", "from", "self", ".", "_check_for_blocking", "(", ")", "if", "not", "jids_to_unblock", ":", "return", "cmd", "=", "blocking_xso", ".", "UnblockCommand", "(", "jids_to_unblock", ")", ...
Remove the JIDs in the sequence `jids_to_block` from the client's blocklist.
[ "Remove", "the", "JIDs", "in", "the", "sequence", "jids_to_block", "from", "the", "client", "s", "blocklist", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/blocking/service.py#L152-L167
820
horazont/aioxmpp
aioxmpp/forms/form.py
DescriptorClass._register_descriptor_keys
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:`AbstractDescripto...
python
def _register_descriptor_keys(self, descriptor, keys): 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_descripto...
[ "def", "_register_descriptor_keys", "(", "self", ",", "descriptor", ",", "keys", ")", ":", "if", "descriptor", ".", "root_class", "is", "not", "self", "or", "self", ".", "__subclasses__", "(", ")", ":", "raise", "TypeError", "(", "\"descriptors cannot be modifie...
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...
[ "Register", "the", "given", "descriptor", "keys", "for", "the", "given", "descriptor", "at", "the", "class", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/forms/form.py#L177-L227
821
horazont/aioxmpp
aioxmpp/forms/form.py
FormClass.from_xso
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` :rais...
python
def from_xso(self, xso): 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 fi...
[ "def", "from_xso", "(", "self", ",", "xso", ")", ":", "my_form_type", "=", "getattr", "(", "self", ",", "\"FORM_TYPE\"", ",", "None", ")", "f", "=", "self", "(", ")", "for", "field", "in", "xso", ".", "fields", ":", "if", "field", ".", "var", "==",...
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...
[ "Construct", "and", "return", "an", "instance", "from", "the", "given", "xso", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/forms/form.py#L231-L307
822
horazont/aioxmpp
aioxmpp/pep/service.py
PEPClient.claim_pep_node
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` ...
python
def claim_pep_node(self, node_namespace, *, register_feature=True, notify=False): if node_namespace in self._pep_node_claims: raise RuntimeError( "claiming already claimed node" ) registered_node = RegisteredPEPNode( self, ...
[ "def", "claim_pep_node", "(", "self", ",", "node_namespace", ",", "*", ",", "register_feature", "=", "True", ",", "notify", "=", "False", ")", ":", "if", "node_namespace", "in", "self", ".", "_pep_node_claims", ":", "raise", "RuntimeError", "(", "\"claiming al...
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 ...
[ "Claim", "node", "node_namespace", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/pep/service.py#L90-L146
823
horazont/aioxmpp
aioxmpp/pep/service.py
PEPClient.available
def available(self): """ Check whether we have a PEP identity associated with our account. """ disco_info = yield from self._disco_client.query_info( self.client.local_jid.bare() ) for item in disco_info.identities.filter(attrs={"category": "pubsub"}): ...
python
def available(self): 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", ")", ":", "disco_info", "=", "yield", "from", "self", ".", "_disco_client", ".", "query_info", "(", "self", ".", "client", ".", "local_jid", ".", "bare", "(", ")", ")", "for", "item", "in", "disco_info", ".", "identities"...
Check whether we have a PEP identity associated with our account.
[ "Check", "whether", "we", "have", "a", "PEP", "identity", "associated", "with", "our", "account", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/pep/service.py#L152-L163
824
horazont/aioxmpp
aioxmpp/pep/service.py
PEPClient.publish
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 represe...
python
def publish(self, node, data, *, id_=None, access_model=None): publish_options = None def autocreate_publish_options(): nonlocal publish_options if publish_options is None: publish_options = aioxmpp.forms.Data( aioxmpp.forms.DataType.SUBMIT ...
[ "def", "publish", "(", "self", ",", "node", ",", "data", ",", "*", ",", "id_", "=", "None", ",", "access_model", "=", "None", ")", ":", "publish_options", "=", "None", "def", "autocreate_publish_options", "(", ")", ":", "nonlocal", "publish_options", "if",...
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. ...
[ "Publish", "an", "item", "data", "in", "the", "PubSub", "node", "node", "on", "the", "PEP", "service", "associated", "with", "the", "user", "s", "JID", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/pep/service.py#L193-L249
825
horazont/aioxmpp
aioxmpp/pep/service.py
RegisteredPEPNode.close
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`. """ if self._closed: return self._closed = True self._pep...
python
def close(self): if self._closed: return self._closed = True self._pep_service._unclaim(self.node_namespace) self._unregister()
[ "def", "close", "(", "self", ")", ":", "if", "self", ".", "_closed", ":", "return", "self", ".", "_closed", "=", "True", "self", ".", "_pep_service", ".", "_unclaim", "(", "self", ".", "node_namespace", ")", "self", ".", "_unregister", "(", ")" ]
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`.
[ "Unclaim", "the", "PEP", "node", "and", "unregister", "the", "registered", "features", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/pep/service.py#L326-L338
826
neo4j-contrib/django-neomodel
django_neomodel/__init__.py
DjangoNode.full_clean
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: """ # validate...
python
def full_clean(self, exclude, validate_unique=False): # 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...
[ "def", "full_clean", "(", "self", ",", "exclude", ",", "validate_unique", "=", "False", ")", ":", "# validate against neomodel", "try", ":", "self", ".", "deflate", "(", "self", ".", "__properties__", ",", "self", ")", "except", "DeflateError", "as", "e", ":...
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:
[ "Validate", "node", "on", "error", "raising", "ValidationErrors", "which", "can", "be", "handled", "by", "django", "forms" ]
9bee6708c0df8e4d1b546fe57e1f735e63a29d81
https://github.com/neo4j-contrib/django-neomodel/blob/9bee6708c0df8e4d1b546fe57e1f735e63a29d81/django_neomodel/__init__.py#L148-L163
827
mishbahr/django-users2
users/models.py
AbstractUser.email_user
def email_user(self, subject, message, from_email=None): """ Send an email to this User.""" send_mail(subject, message, from_email, [self.email])
python
def email_user(self, subject, message, from_email=None): send_mail(subject, message, from_email, [self.email])
[ "def", "email_user", "(", "self", ",", "subject", ",", "message", ",", "from_email", "=", "None", ")", ":", "send_mail", "(", "subject", ",", "message", ",", "from_email", ",", "[", "self", ".", "email", "]", ")" ]
Send an email to this User.
[ "Send", "an", "email", "to", "this", "User", "." ]
1ee244dc4ca162b2331d2a44d45848fdcb80f329
https://github.com/mishbahr/django-users2/blob/1ee244dc4ca162b2331d2a44d45848fdcb80f329/users/models.py#L47-L49
828
mishbahr/django-users2
users/admin.py
UserAdmin.activate_users
def activate_users(self, request, queryset): """ Activates the selected users, if they are not already activated. """ n = 0 for user in queryset: if not user.is_active: user.activate() n += 1 self.message_user( ...
python
def activate_users(self, request, queryset): 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, 'item...
[ "def", "activate_users", "(", "self", ",", "request", ",", "queryset", ")", ":", "n", "=", "0", "for", "user", "in", "queryset", ":", "if", "not", "user", ".", "is_active", ":", "user", ".", "activate", "(", ")", "n", "+=", "1", "self", ".", "messa...
Activates the selected users, if they are not already activated.
[ "Activates", "the", "selected", "users", "if", "they", "are", "not", "already", "activated", "." ]
1ee244dc4ca162b2331d2a44d45848fdcb80f329
https://github.com/mishbahr/django-users2/blob/1ee244dc4ca162b2331d2a44d45848fdcb80f329/users/admin.py#L79-L93
829
mishbahr/django-users2
users/admin.py
UserAdmin.send_activation_email
def send_activation_email(self, request, queryset): """ Send activation emails for the selected users, if they are not already activated. """ n = 0 for user in queryset: if not user.is_active and settings.USERS_VERIFY_EMAIL: send_activation_ema...
python
def send_activation_email(self, request, queryset): 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 email...
[ "def", "send_activation_email", "(", "self", ",", "request", ",", "queryset", ")", ":", "n", "=", "0", "for", "user", "in", "queryset", ":", "if", "not", "user", ".", "is_active", "and", "settings", ".", "USERS_VERIFY_EMAIL", ":", "send_activation_email", "(...
Send activation emails for the selected users, if they are not already activated.
[ "Send", "activation", "emails", "for", "the", "selected", "users", "if", "they", "are", "not", "already", "activated", "." ]
1ee244dc4ca162b2331d2a44d45848fdcb80f329
https://github.com/mishbahr/django-users2/blob/1ee244dc4ca162b2331d2a44d45848fdcb80f329/users/admin.py#L96-L109
830
mishbahr/django-users2
users/managers.py
UserManager.get_queryset
def get_queryset(self): """ Fixes get_query_set vs get_queryset for Django <1.6 """ try: qs = super(UserManager, self).get_queryset() except AttributeError: # pragma: no cover qs = super(UserManager, self).get_query_set() return qs
python
def get_queryset(self): 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", ")", ":", "try", ":", "qs", "=", "super", "(", "UserManager", ",", "self", ")", ".", "get_queryset", "(", ")", "except", "AttributeError", ":", "# pragma: no cover", "qs", "=", "super", "(", "UserManager", ",", "self", ...
Fixes get_query_set vs get_queryset for Django <1.6
[ "Fixes", "get_query_set", "vs", "get_queryset", "for", "Django", "<1", ".", "6" ]
1ee244dc4ca162b2331d2a44d45848fdcb80f329
https://github.com/mishbahr/django-users2/blob/1ee244dc4ca162b2331d2a44d45848fdcb80f329/users/managers.py#L11-L19
831
eandersson/amqpstorm
amqpstorm/io.py
Poller.is_ready
def is_ready(self): """Is Socket Ready. :rtype: tuple """ try: ready, _, _ = self.select.select([self.fileno], [], [], POLL_TIMEOUT) return bool(ready) except self.select.error as why: if why.args[0...
python
def is_ready(self): 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(AMQPConnect...
[ "def", "is_ready", "(", "self", ")", ":", "try", ":", "ready", ",", "_", ",", "_", "=", "self", ".", "select", ".", "select", "(", "[", "self", ".", "fileno", "]", ",", "[", "]", ",", "[", "]", ",", "POLL_TIMEOUT", ")", "return", "bool", "(", ...
Is Socket Ready. :rtype: tuple
[ "Is", "Socket", "Ready", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/io.py#L39-L51
832
eandersson/amqpstorm
amqpstorm/io.py
IO.close
def close(self): """Close Socket. :return: """ self._wr_lock.acquire() self._rd_lock.acquire() try: self._running.clear() if self.socket: self._close_socket() if self._inbound_thread: self._inbound_threa...
python
def close(self): 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']) ...
[ "def", "close", "(", "self", ")", ":", "self", ".", "_wr_lock", ".", "acquire", "(", ")", "self", ".", "_rd_lock", ".", "acquire", "(", ")", "try", ":", "self", ".", "_running", ".", "clear", "(", ")", "if", "self", ".", "socket", ":", "self", "....
Close Socket. :return:
[ "Close", "Socket", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/io.py#L70-L88
833
eandersson/amqpstorm
amqpstorm/io.py
IO.open
def open(self): """Open Socket and establish a connection. :raises AMQPConnectionError: Raises if the connection encountered an error. :return: """ self._wr_lock.acquire() self._rd_lock.acquire() try: self.data_in ...
python
def open(self): 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 ...
[ "def", "open", "(", "self", ")", ":", "self", ".", "_wr_lock", ".", "acquire", "(", ")", "self", ".", "_rd_lock", ".", "acquire", "(", ")", "try", ":", "self", ".", "data_in", "=", "EMPTY_BUFFER", "self", ".", "_running", ".", "set", "(", ")", "soc...
Open Socket and establish a connection. :raises AMQPConnectionError: Raises if the connection encountered an error. :return:
[ "Open", "Socket", "and", "establish", "a", "connection", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/io.py#L90-L109
834
eandersson/amqpstorm
amqpstorm/io.py
IO.write_to_socket
def write_to_socket(self, frame_data): """Write data to the socket. :param str frame_data: :return: """ self._wr_lock.acquire() try: total_bytes_written = 0 bytes_to_send = len(frame_data) while total_bytes_written < bytes_to_send: ...
python
def write_to_socket(self, frame_data): 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.err...
[ "def", "write_to_socket", "(", "self", ",", "frame_data", ")", ":", "self", ".", "_wr_lock", ".", "acquire", "(", ")", "try", ":", "total_bytes_written", "=", "0", "bytes_to_send", "=", "len", "(", "frame_data", ")", "while", "total_bytes_written", "<", "byt...
Write data to the socket. :param str frame_data: :return:
[ "Write", "data", "to", "the", "socket", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/io.py#L111-L139
835
eandersson/amqpstorm
amqpstorm/io.py
IO._close_socket
def _close_socket(self): """Shutdown and close the Socket. :return: """ try: self.socket.shutdown(socket.SHUT_RDWR) except (OSError, socket.error): pass self.socket.close()
python
def _close_socket(self): try: self.socket.shutdown(socket.SHUT_RDWR) except (OSError, socket.error): pass self.socket.close()
[ "def", "_close_socket", "(", "self", ")", ":", "try", ":", "self", ".", "socket", ".", "shutdown", "(", "socket", ".", "SHUT_RDWR", ")", "except", "(", "OSError", ",", "socket", ".", "error", ")", ":", "pass", "self", ".", "socket", ".", "close", "("...
Shutdown and close the Socket. :return:
[ "Shutdown", "and", "close", "the", "Socket", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/io.py#L141-L150
836
eandersson/amqpstorm
amqpstorm/io.py
IO._get_socket_addresses
def _get_socket_addresses(self): """Get Socket address information. :rtype: list """ family = socket.AF_UNSPEC if not socket.has_ipv6: family = socket.AF_INET try: addresses = socket.getaddrinfo(self._parameters['hostname'], ...
python
def _get_socket_addresses(self): family = socket.AF_UNSPEC if not socket.has_ipv6: family = socket.AF_INET try: addresses = socket.getaddrinfo(self._parameters['hostname'], self._parameters['port'], family, ...
[ "def", "_get_socket_addresses", "(", "self", ")", ":", "family", "=", "socket", ".", "AF_UNSPEC", "if", "not", "socket", ".", "has_ipv6", ":", "family", "=", "socket", ".", "AF_INET", "try", ":", "addresses", "=", "socket", ".", "getaddrinfo", "(", "self",...
Get Socket address information. :rtype: list
[ "Get", "Socket", "address", "information", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/io.py#L152-L166
837
eandersson/amqpstorm
amqpstorm/io.py
IO._find_address_and_connect
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 """ error_message = ...
python
def _find_address_and_connect(self, addresses): 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.stre...
[ "def", "_find_address_and_connect", "(", "self", ",", "addresses", ")", ":", "error_message", "=", "None", "for", "address", "in", "addresses", ":", "sock", "=", "self", ".", "_create_socket", "(", "socket_family", "=", "address", "[", "0", "]", ")", "try", ...
Find and connect to the appropriate address. :param addresses: :raises AMQPConnectionError: Raises if the connection encountered an error. :rtype: socket.socket
[ "Find", "and", "connect", "to", "the", "appropriate", "address", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/io.py#L168-L192
838
eandersson/amqpstorm
amqpstorm/io.py
IO._create_socket
def _create_socket(self, socket_family): """Create Socket. :param int socket_family: :rtype: socket.socket """ sock = socket.socket(socket_family, socket.SOCK_STREAM, 0) sock.settimeout(self._parameters['timeout'] or None) if self.use_ssl: if not comp...
python
def _create_socket(self, socket_family): 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 com...
[ "def", "_create_socket", "(", "self", ",", "socket_family", ")", ":", "sock", "=", "socket", ".", "socket", "(", "socket_family", ",", "socket", ".", "SOCK_STREAM", ",", "0", ")", "sock", ".", "settimeout", "(", "self", ".", "_parameters", "[", "'timeout'"...
Create Socket. :param int socket_family: :rtype: socket.socket
[ "Create", "Socket", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/io.py#L194-L208
839
eandersson/amqpstorm
amqpstorm/io.py
IO._ssl_wrap_socket
def _ssl_wrap_socket(self, sock): """Wrap SSLSocket around the Socket. :param socket.socket sock: :rtype: SSLSocket """ context = self._parameters['ssl_options'].get('context') if context is not None: hostname = self._parameters['ssl_options'].get('server_hos...
python
def _ssl_wrap_socket(self, sock): 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, ser...
[ "def", "_ssl_wrap_socket", "(", "self", ",", "sock", ")", ":", "context", "=", "self", ".", "_parameters", "[", "'ssl_options'", "]", ".", "get", "(", "'context'", ")", "if", "context", "is", "not", "None", ":", "hostname", "=", "self", ".", "_parameters...
Wrap SSLSocket around the Socket. :param socket.socket sock: :rtype: SSLSocket
[ "Wrap", "SSLSocket", "around", "the", "Socket", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/io.py#L210-L230
840
eandersson/amqpstorm
amqpstorm/io.py
IO._create_inbound_thread
def _create_inbound_thread(self): """Internal Thread that handles all incoming traffic. :rtype: threading.Thread """ inbound_thread = threading.Thread(target=self._process_incoming_data, name=__name__) inbound_thread.daemon = True ...
python
def _create_inbound_thread(self): 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", ")", ":", "inbound_thread", "=", "threading", ".", "Thread", "(", "target", "=", "self", ".", "_process_incoming_data", ",", "name", "=", "__name__", ")", "inbound_thread", ".", "daemon", "=", "True", "inbound_thread...
Internal Thread that handles all incoming traffic. :rtype: threading.Thread
[ "Internal", "Thread", "that", "handles", "all", "incoming", "traffic", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/io.py#L232-L241
841
eandersson/amqpstorm
amqpstorm/io.py
IO._process_incoming_data
def _process_incoming_data(self): """Retrieve and process any incoming data. :return: """ 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)
python
def _process_incoming_data(self): 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", ")", ":", "while", "self", ".", "_running", ".", "is_set", "(", ")", ":", "if", "self", ".", "poller", ".", "is_ready", ":", "self", ".", "data_in", "+=", "self", ".", "_receive", "(", ")", "self", ".", "...
Retrieve and process any incoming data. :return:
[ "Retrieve", "and", "process", "any", "incoming", "data", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/io.py#L243-L251
842
eandersson/amqpstorm
amqpstorm/io.py
IO._receive
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 """ data_in = EMPTY_BUFFER try: data_in = self._read_from_socket() except socket.timeout:...
python
def _receive(self): 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(wh...
[ "def", "_receive", "(", "self", ")", ":", "data_in", "=", "EMPTY_BUFFER", "try", ":", "data_in", "=", "self", ".", "_read_from_socket", "(", ")", "except", "socket", ".", "timeout", ":", "pass", "except", "(", "IOError", ",", "OSError", ")", "as", "why",...
Receive any incoming socket data. If an error is thrown, handle it and return an empty string. :return: data_in :rtype: bytes
[ "Receive", "any", "incoming", "socket", "data", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/io.py#L253-L270
843
eandersson/amqpstorm
amqpstorm/io.py
IO._read_from_socket
def _read_from_socket(self): """Read data from the socket. :rtype: bytes """ 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...
python
def _read_from_socket(self): 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 e...
[ "def", "_read_from_socket", "(", "self", ")", ":", "if", "not", "self", ".", "use_ssl", ":", "if", "not", "self", ".", "socket", ":", "raise", "socket", ".", "error", "(", "'connection/socket error'", ")", "return", "self", ".", "socket", ".", "recv", "(...
Read data from the socket. :rtype: bytes
[ "Read", "data", "from", "the", "socket", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/io.py#L272-L285
844
eandersson/amqpstorm
amqpstorm/heartbeat.py
Heartbeat.start
def start(self, exceptions): """Start the Heartbeat Checker. :param list exceptions: :return: """ if not self._interval: return False self._running.set() with self._lock: self._threshold = 0 self._reads_since_check = 0 ...
python
def start(self, exceptions): 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...
[ "def", "start", "(", "self", ",", "exceptions", ")", ":", "if", "not", "self", ".", "_interval", ":", "return", "False", "self", ".", "_running", ".", "set", "(", ")", "with", "self", ".", "_lock", ":", "self", ".", "_threshold", "=", "0", "self", ...
Start the Heartbeat Checker. :param list exceptions: :return:
[ "Start", "the", "Heartbeat", "Checker", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/heartbeat.py#L40-L55
845
eandersson/amqpstorm
amqpstorm/heartbeat.py
Heartbeat.stop
def stop(self): """Stop the Heartbeat Checker. :return: """ self._running.clear() with self._lock: if self._timer: self._timer.cancel() self._timer = None
python
def stop(self): self._running.clear() with self._lock: if self._timer: self._timer.cancel() self._timer = None
[ "def", "stop", "(", "self", ")", ":", "self", ".", "_running", ".", "clear", "(", ")", "with", "self", ".", "_lock", ":", "if", "self", ".", "_timer", ":", "self", ".", "_timer", ".", "cancel", "(", ")", "self", ".", "_timer", "=", "None" ]
Stop the Heartbeat Checker. :return:
[ "Stop", "the", "Heartbeat", "Checker", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/heartbeat.py#L57-L66
846
eandersson/amqpstorm
amqpstorm/heartbeat.py
Heartbeat._check_for_life_signs
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...
python
def _check_for_life_signs(self): 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...
[ "def", "_check_for_life_signs", "(", "self", ")", ":", "if", "not", "self", ".", "_running", ".", "is_set", "(", ")", ":", "return", "False", "if", "self", ".", "_writes_since_check", "==", "0", ":", "self", ".", "send_heartbeat_impl", "(", ")", "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. ...
[ "Check", "Connection", "for", "life", "signs", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/heartbeat.py#L68-L99
847
eandersson/amqpstorm
amqpstorm/heartbeat.py
Heartbeat._raise_or_append_exception
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: """ ...
python
def _raise_or_append_exception(self): message = ( 'Connection dead, no heartbeat or data received in >= ' '%ds' % ( self._interval * 2 ) ) why = AMQPConnectionError(message) if self._exceptions is None: raise why sel...
[ "def", "_raise_or_append_exception", "(", "self", ")", ":", "message", "=", "(", "'Connection dead, no heartbeat or data received in >= '", "'%ds'", "%", "(", "self", ".", "_interval", "*", "2", ")", ")", "why", "=", "AMQPConnectionError", "(", "message", ")", "if...
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:
[ "The", "connection", "is", "presumably", "dead", "and", "we", "need", "to", "raise", "or", "append", "an", "exception", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/heartbeat.py#L101-L119
848
eandersson/amqpstorm
amqpstorm/heartbeat.py
Heartbeat._start_new_timer
def _start_new_timer(self): """Create a timer that will be used to periodically check the connection for heartbeats. :return: """ if not self._running.is_set(): return False self._timer = self.timer_impl( interval=self._interval, funct...
python
def _start_new_timer(self): 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", ")", ":", "if", "not", "self", ".", "_running", ".", "is_set", "(", ")", ":", "return", "False", "self", ".", "_timer", "=", "self", ".", "timer_impl", "(", "interval", "=", "self", ".", "_interval", ",", "functi...
Create a timer that will be used to periodically check the connection for heartbeats. :return:
[ "Create", "a", "timer", "that", "will", "be", "used", "to", "periodically", "check", "the", "connection", "for", "heartbeats", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/heartbeat.py#L121-L135
849
eandersson/amqpstorm
amqpstorm/management/queue.py
Queue.get
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. :...
python
def get(self, queue, virtual_host='/'): virtual_host = quote(virtual_host, '') return self.http_client.get( API_QUEUE % ( virtual_host, queue ) )
[ "def", "get", "(", "self", ",", "queue", ",", "virtual_host", "=", "'/'", ")", ":", "virtual_host", "=", "quote", "(", "virtual_host", ",", "''", ")", "return", "self", ".", "http_client", ".", "get", "(", "API_QUEUE", "%", "(", "virtual_host", ",", "q...
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
[ "Get", "Queue", "details", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/management/queue.py#L15-L32
850
eandersson/amqpstorm
amqpstorm/management/queue.py
Queue.list
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 ...
python
def list(self, virtual_host='/', show_all=False): 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", ")", ":", "if", "show_all", ":", "return", "self", ".", "http_client", ".", "get", "(", "API_QUEUES", ")", "virtual_host", "=", "quote", "(", "virtual_host", ",",...
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
[ "List", "Queues", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/management/queue.py#L34-L50
851
eandersson/amqpstorm
amqpstorm/management/queue.py
Queue.bindings
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. ...
python
def bindings(self, queue, virtual_host='/'): virtual_host = quote(virtual_host, '') return self.http_client.get(API_QUEUE_BINDINGS % ( virtual_host, queue ...
[ "def", "bindings", "(", "self", ",", "queue", ",", "virtual_host", "=", "'/'", ")", ":", "virtual_host", "=", "quote", "(", "virtual_host", ",", "''", ")", "return", "self", ".", "http_client", ".", "get", "(", "API_QUEUE_BINDINGS", "%", "(", "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
[ "Get", "Queue", "bindings", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/management/queue.py#L122-L138
852
eandersson/amqpstorm
amqpstorm/management/exchange.py
Exchange.get
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 i...
python
def get(self, exchange, virtual_host='/'): virtual_host = quote(virtual_host, '') return self.http_client.get( API_EXCHANGE % ( virtual_host, exchange) )
[ "def", "get", "(", "self", ",", "exchange", ",", "virtual_host", "=", "'/'", ")", ":", "virtual_host", "=", "quote", "(", "virtual_host", ",", "''", ")", "return", "self", ".", "http_client", ".", "get", "(", "API_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
[ "Get", "Exchange", "details", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/management/exchange.py#L14-L31
853
eandersson/amqpstorm
amqpstorm/management/exchange.py
Exchange.list
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 connect...
python
def list(self, virtual_host='/', show_all=False): 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", ")", ":", "if", "show_all", ":", "return", "self", ".", "http_client", ".", "get", "(", "API_EXCHANGES", ")", "virtual_host", "=", "quote", "(", "virtual_host", "...
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
[ "List", "Exchanges", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/management/exchange.py#L33-L49
854
eandersson/amqpstorm
amqpstorm/management/exchange.py
Exchange.bindings
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 connecti...
python
def bindings(self, exchange, virtual_host='/'): virtual_host = quote(virtual_host, '') return self.http_client.get(API_EXCHANGE_BINDINGS % ( virtual_host, exchange ...
[ "def", "bindings", "(", "self", ",", "exchange", ",", "virtual_host", "=", "'/'", ")", ":", "virtual_host", "=", "quote", "(", "virtual_host", ",", "''", ")", "return", "self", ".", "http_client", ".", "get", "(", "API_EXCHANGE_BINDINGS", "%", "(", "virtua...
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
[ "Get", "Exchange", "bindings", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/management/exchange.py#L107-L123
855
eandersson/amqpstorm
amqpstorm/connection.py
Connection.check_for_errors
def check_for_errors(self): """Check Connection for errors. :raises AMQPConnectionError: Raises if the connection encountered an error. :return: """ if not self.exceptions: if not self.is_closed: return ...
python
def check_for_errors(self): 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", ")", ":", "if", "not", "self", ".", "exceptions", ":", "if", "not", "self", ".", "is_closed", ":", "return", "why", "=", "AMQPConnectionError", "(", "'connection was closed'", ")", "self", ".", "exceptions", ".", "appe...
Check Connection for errors. :raises AMQPConnectionError: Raises if the connection encountered an error. :return:
[ "Check", "Connection", "for", "errors", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/connection.py#L172-L186
856
eandersson/amqpstorm
amqpstorm/connection.py
Connection.open
def open(self): """Open Connection. :raises AMQPConnectionError: Raises if the connection encountered an error. """ LOGGER.debug('Connection Opening') self.set_state(self.OPENING) self._exceptions = [] self._channels = {} ...
python
def open(self): 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....
[ "def", "open", "(", "self", ")", ":", "LOGGER", ".", "debug", "(", "'Connection Opening'", ")", "self", ".", "set_state", "(", "self", ".", "OPENING", ")", "self", ".", "_exceptions", "=", "[", "]", "self", ".", "_channels", "=", "{", "}", "self", "....
Open Connection. :raises AMQPConnectionError: Raises if the connection encountered an error.
[ "Open", "Connection", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/connection.py#L211-L226
857
eandersson/amqpstorm
amqpstorm/connection.py
Connection.write_frame
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: """ frame_data = pamqp_frame.marshal(frame_out, channel_id) se...
python
def write_frame(self, channel_id, frame_out): 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", ")", ":", "frame_data", "=", "pamqp_frame", ".", "marshal", "(", "frame_out", ",", "channel_id", ")", "self", ".", "heartbeat", ".", "register_write", "(", ")", "self", ".", "_io", "."...
Marshal and write an outgoing pamqp frame to the Socket. :param int channel_id: Channel ID. :param specification.Frame frame_out: Amqp frame. :return:
[ "Marshal", "and", "write", "an", "outgoing", "pamqp", "frame", "to", "the", "Socket", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/connection.py#L228-L238
858
eandersson/amqpstorm
amqpstorm/connection.py
Connection.write_frames
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: """ data_out = EMPTY_BUFFER for single_frame in frames_out: ...
python
def write_frames(self, channel_id, frames_out): 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", ")", ":", "data_out", "=", "EMPTY_BUFFER", "for", "single_frame", "in", "frames_out", ":", "data_out", "+=", "pamqp_frame", ".", "marshal", "(", "single_frame", ",", "channel_id", ")", "...
Marshal and write multiple outgoing pamqp frames to the Socket. :param int channel_id: Channel ID/ :param list frames_out: Amqp frames. :return:
[ "Marshal", "and", "write", "multiple", "outgoing", "pamqp", "frames", "to", "the", "Socket", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/connection.py#L240-L252
859
eandersson/amqpstorm
amqpstorm/connection.py
Connection._close_remaining_channels
def _close_remaining_channels(self): """Forcefully close all open channels. :return: """ 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)
python
def _close_remaining_channels(self): 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", ")", ":", "for", "channel_id", "in", "list", "(", "self", ".", "_channels", ")", ":", "self", ".", "_channels", "[", "channel_id", "]", ".", "set_state", "(", "Channel", ".", "CLOSED", ")", "self", ".", "_...
Forcefully close all open channels. :return:
[ "Forcefully", "close", "all", "open", "channels", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/connection.py#L254-L262
860
eandersson/amqpstorm
amqpstorm/connection.py
Connection._handle_amqp_frame
def _handle_amqp_frame(self, data_in): """Unmarshal a single AMQP frame and return the result. :param data_in: socket data :return: data_in, channel_id, frame """ if not data_in: return data_in, None, None try: byte_count, channel_id, frame_in = ...
python
def _handle_amqp_frame(self, data_in): if not data_in: return data_in, None, None try: byte_count, channel_id, frame_in = pamqp_frame.unmarshal(data_in) return data_in[byte_count:], channel_id, frame_in except pamqp_exception.UnmarshalingException: ...
[ "def", "_handle_amqp_frame", "(", "self", ",", "data_in", ")", ":", "if", "not", "data_in", ":", "return", "data_in", ",", "None", ",", "None", "try", ":", "byte_count", ",", "channel_id", ",", "frame_in", "=", "pamqp_frame", ".", "unmarshal", "(", "data_i...
Unmarshal a single AMQP frame and return the result. :param data_in: socket data :return: data_in, channel_id, frame
[ "Unmarshal", "a", "single", "AMQP", "frame", "and", "return", "the", "result", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/connection.py#L284-L303
861
eandersson/amqpstorm
amqpstorm/connection.py
Connection._read_buffer
def _read_buffer(self, data_in): """Process the socket buffer, and direct the data to the appropriate channel. :rtype: bytes """ while data_in: data_in, channel_id, frame_in = self._handle_amqp_frame(data_in) if frame_in is None: break ...
python
def _read_buffer(self, data_in): while data_in: data_in, channel_id, frame_in = self._handle_amqp_frame(data_in) if frame_in is None: break self.heartbeat.register_read() if channel_id == 0: self._channel0.on_frame(frame_in) ...
[ "def", "_read_buffer", "(", "self", ",", "data_in", ")", ":", "while", "data_in", ":", "data_in", ",", "channel_id", ",", "frame_in", "=", "self", ".", "_handle_amqp_frame", "(", "data_in", ")", "if", "frame_in", "is", "None", ":", "break", "self", ".", ...
Process the socket buffer, and direct the data to the appropriate channel. :rtype: bytes
[ "Process", "the", "socket", "buffer", "and", "direct", "the", "data", "to", "the", "appropriate", "channel", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/connection.py#L305-L323
862
eandersson/amqpstorm
amqpstorm/connection.py
Connection._cleanup_channel
def _cleanup_channel(self, channel_id): """Remove the the channel from the list of available channels. :param int channel_id: Channel id :return: """ with self.lock: if channel_id not in self._channels: return del self._channels[channel_i...
python
def _cleanup_channel(self, channel_id): with self.lock: if channel_id not in self._channels: return del self._channels[channel_id]
[ "def", "_cleanup_channel", "(", "self", ",", "channel_id", ")", ":", "with", "self", ".", "lock", ":", "if", "channel_id", "not", "in", "self", ".", "_channels", ":", "return", "del", "self", ".", "_channels", "[", "channel_id", "]" ]
Remove the the channel from the list of available channels. :param int channel_id: Channel id :return:
[ "Remove", "the", "the", "channel", "from", "the", "list", "of", "available", "channels", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/connection.py#L325-L335
863
eandersson/amqpstorm
amqpstorm/connection.py
Connection._validate_parameters
def _validate_parameters(self): """Validate Connection Parameters. :return: """ if not compatibility.is_string(self.parameters['hostname']): raise AMQPInvalidArgument('hostname should be a string') elif not compatibility.is_integer(self.parameters['port']): ...
python
def _validate_parameters(self): if not compatibility.is_string(self.parameters['hostname']): raise AMQPInvalidArgument('hostname should be a string') elif not compatibility.is_integer(self.parameters['port']): raise AMQPInvalidArgument('port should be an integer') elif no...
[ "def", "_validate_parameters", "(", "self", ")", ":", "if", "not", "compatibility", ".", "is_string", "(", "self", ".", "parameters", "[", "'hostname'", "]", ")", ":", "raise", "AMQPInvalidArgument", "(", "'hostname should be a string'", ")", "elif", "not", "com...
Validate Connection Parameters. :return:
[ "Validate", "Connection", "Parameters", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/connection.py#L344-L362
864
eandersson/amqpstorm
amqpstorm/connection.py
Connection._wait_for_connection_state
def _wait_for_connection_state(self, state=Stateful.OPEN, rpc_timeout=30): """Wait for a Connection state. :param int state: State that we expect :raises AMQPConnectionError: Raises if we are unable to establish a connection to RabbitMQ. :return: ...
python
def _wait_for_connection_state(self, state=Stateful.OPEN, rpc_timeout=30): start_time = time.time() while self.current_state != state: self.check_for_errors() if time.time() - start_time > rpc_timeout: raise AMQPConnectionError('Connection timed out') ...
[ "def", "_wait_for_connection_state", "(", "self", ",", "state", "=", "Stateful", ".", "OPEN", ",", "rpc_timeout", "=", "30", ")", ":", "start_time", "=", "time", ".", "time", "(", ")", "while", "self", ".", "current_state", "!=", "state", ":", "self", "....
Wait for a Connection state. :param int state: State that we expect :raises AMQPConnectionError: Raises if we are unable to establish a connection to RabbitMQ. :return:
[ "Wait", "for", "a", "Connection", "state", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/connection.py#L364-L379
865
eandersson/amqpstorm
examples/robust_consumer.py
Consumer.start
def start(self): """Start the Consumers. :return: """ if not self.connection: self.create_connection() while True: try: channel = self.connection.channel() channel.queue.declare('simple_queue') channel.basic...
python
def start(self): if not self.connection: self.create_connection() while True: try: channel = self.connection.channel() channel.queue.declare('simple_queue') channel.basic.consume(self, 'simple_queue', no_ack=False) c...
[ "def", "start", "(", "self", ")", ":", "if", "not", "self", ".", "connection", ":", "self", ".", "create_connection", "(", ")", "while", "True", ":", "try", ":", "channel", "=", "self", ".", "connection", ".", "channel", "(", ")", "channel", ".", "qu...
Start the Consumers. :return:
[ "Start", "the", "Consumers", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/examples/robust_consumer.py#L39-L59
866
eandersson/amqpstorm
examples/scalable_consumer.py
ScalableConsumer.stop
def stop(self): """Stop all consumers. :return: """ while self._consumers: consumer = self._consumers.pop() consumer.stop() self._stopped.set() self._connection.close()
python
def stop(self): while self._consumers: consumer = self._consumers.pop() consumer.stop() self._stopped.set() self._connection.close()
[ "def", "stop", "(", "self", ")", ":", "while", "self", ".", "_consumers", ":", "consumer", "=", "self", ".", "_consumers", ".", "pop", "(", ")", "consumer", ".", "stop", "(", ")", "self", ".", "_stopped", ".", "set", "(", ")", "self", ".", "_connec...
Stop all consumers. :return:
[ "Stop", "all", "consumers", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/examples/scalable_consumer.py#L69-L78
867
eandersson/amqpstorm
examples/scalable_consumer.py
ScalableConsumer._stop_consumers
def _stop_consumers(self, number_of_consumers=0): """Stop a specific number of consumers. :param number_of_consumers: :return: """ while len(self._consumers) > number_of_consumers: consumer = self._consumers.pop() consumer.stop()
python
def _stop_consumers(self, number_of_consumers=0): while len(self._consumers) > number_of_consumers: consumer = self._consumers.pop() consumer.stop()
[ "def", "_stop_consumers", "(", "self", ",", "number_of_consumers", "=", "0", ")", ":", "while", "len", "(", "self", ".", "_consumers", ")", ">", "number_of_consumers", ":", "consumer", "=", "self", ".", "_consumers", ".", "pop", "(", ")", "consumer", ".", ...
Stop a specific number of consumers. :param number_of_consumers: :return:
[ "Stop", "a", "specific", "number", "of", "consumers", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/examples/scalable_consumer.py#L131-L139
868
eandersson/amqpstorm
examples/scalable_consumer.py
ScalableConsumer._start_consumer
def _start_consumer(self, consumer): """Start a consumer as a new Thread. :param Consumer consumer: :return: """ thread = threading.Thread(target=consumer.start, args=(self._connection,)) thread.daemon = True thread.start()
python
def _start_consumer(self, consumer): thread = threading.Thread(target=consumer.start, args=(self._connection,)) thread.daemon = True thread.start()
[ "def", "_start_consumer", "(", "self", ",", "consumer", ")", ":", "thread", "=", "threading", ".", "Thread", "(", "target", "=", "consumer", ".", "start", ",", "args", "=", "(", "self", ".", "_connection", ",", ")", ")", "thread", ".", "daemon", "=", ...
Start a consumer as a new Thread. :param Consumer consumer: :return:
[ "Start", "a", "consumer", "as", "a", "new", "Thread", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/examples/scalable_consumer.py#L141-L150
869
eandersson/amqpstorm
amqpstorm/tx.py
Tx.select
def select(self): """Enable standard transaction mode. This will enable transaction mode on the channel. Meaning that messages will be kept in the remote server buffer until such a time that either commit or rollback is called. :return: """ self._tx_...
python
def select(self): self._tx_active = True return self._channel.rpc_request(specification.Tx.Select())
[ "def", "select", "(", "self", ")", ":", "self", ".", "_tx_active", "=", "True", "return", "self", ".", "_channel", ".", "rpc_request", "(", "specification", ".", "Tx", ".", "Select", "(", ")", ")" ]
Enable standard transaction mode. This will enable transaction mode on the channel. Meaning that messages will be kept in the remote server buffer until such a time that either commit or rollback is called. :return:
[ "Enable", "standard", "transaction", "mode", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/tx.py#L41-L51
870
eandersson/amqpstorm
amqpstorm/tx.py
Tx.rollback
def rollback(self): """Abandon the current transaction. Rollback all messages published during the current transaction session to the remote server. Note that all messages published during this transaction session will be lost, and will have to be published agai...
python
def rollback(self): self._tx_active = False return self._channel.rpc_request(specification.Tx.Rollback())
[ "def", "rollback", "(", "self", ")", ":", "self", ".", "_tx_active", "=", "False", "return", "self", ".", "_channel", ".", "rpc_request", "(", "specification", ".", "Tx", ".", "Rollback", "(", ")", ")" ]
Abandon the current transaction. Rollback all messages published during the current transaction session to the remote server. Note that all messages published during this transaction session will be lost, and will have to be published again. A new transacti...
[ "Abandon", "the", "current", "transaction", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/tx.py#L67-L82
871
eandersson/amqpstorm
examples/flask_threaded_rpc_client.py
rpc_call
def rpc_call(payload): """Simple Flask implementation for making asynchronous Rpc calls. """ # Send the request and store the requests Unique ID. corr_id = RPC_CLIENT.send_request(payload) # Wait until we have received a response. while RPC_CLIENT.queue[corr_id] is None: sleep(0.1) # ...
python
def rpc_call(payload): # Send the request and store the requests Unique ID. corr_id = RPC_CLIENT.send_request(payload) # Wait until we have received a response. while RPC_CLIENT.queue[corr_id] is None: sleep(0.1) # Return the response to the user. return RPC_CLIENT.queue[corr_id]
[ "def", "rpc_call", "(", "payload", ")", ":", "# Send the request and store the requests Unique ID.", "corr_id", "=", "RPC_CLIENT", ".", "send_request", "(", "payload", ")", "# Wait until we have received a response.", "while", "RPC_CLIENT", ".", "queue", "[", "corr_id", "...
Simple Flask implementation for making asynchronous Rpc calls.
[ "Simple", "Flask", "implementation", "for", "making", "asynchronous", "Rpc", "calls", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/examples/flask_threaded_rpc_client.py#L73-L84
872
eandersson/amqpstorm
examples/flask_threaded_rpc_client.py
RpcClient._create_process_thread
def _create_process_thread(self): """Create a thread responsible for consuming messages in response to RPC requests. """ thread = threading.Thread(target=self._process_data_events) thread.setDaemon(True) thread.start()
python
def _create_process_thread(self): thread = threading.Thread(target=self._process_data_events) thread.setDaemon(True) thread.start()
[ "def", "_create_process_thread", "(", "self", ")", ":", "thread", "=", "threading", ".", "Thread", "(", "target", "=", "self", ".", "_process_data_events", ")", "thread", ".", "setDaemon", "(", "True", ")", "thread", ".", "start", "(", ")" ]
Create a thread responsible for consuming messages in response to RPC requests.
[ "Create", "a", "thread", "responsible", "for", "consuming", "messages", "in", "response", "to", "RPC", "requests", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/examples/flask_threaded_rpc_client.py#L38-L44
873
eandersson/amqpstorm
amqpstorm/message.py
Message.create
def create(channel, body, properties=None): """Create a new Message. :param Channel channel: AMQPStorm Channel :param bytes|str|unicode body: Message payload :param dict properties: Message properties :rtype: Message """ properties = properties or {} if ...
python
def create(channel, body, properties=None): properties = properties or {} if 'correlation_id' not in properties: properties['correlation_id'] = str(uuid.uuid4()) if 'message_id' not in properties: properties['message_id'] = str(uuid.uuid4()) if 'timestamp' not in ...
[ "def", "create", "(", "channel", ",", "body", ",", "properties", "=", "None", ")", ":", "properties", "=", "properties", "or", "{", "}", "if", "'correlation_id'", "not", "in", "properties", ":", "properties", "[", "'correlation_id'", "]", "=", "str", "(", ...
Create a new Message. :param Channel channel: AMQPStorm Channel :param bytes|str|unicode body: Message payload :param dict properties: Message properties :rtype: Message
[ "Create", "a", "new", "Message", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/message.py#L32-L50
874
eandersson/amqpstorm
amqpstorm/message.py
Message.body
def body(self): """Return the Message Body. If auto_decode is enabled, the body will automatically be decoded using decode('utf-8') if possible. :rtype: bytes|str|unicode """ if not self._auto_decode: return self._body if 'body' in self._deco...
python
def body(self): if not self._auto_decode: return self._body if 'body' in self._decode_cache: return self._decode_cache['body'] body = try_utf8_decode(self._body) self._decode_cache['body'] = body return body
[ "def", "body", "(", "self", ")", ":", "if", "not", "self", ".", "_auto_decode", ":", "return", "self", ".", "_body", "if", "'body'", "in", "self", ".", "_decode_cache", ":", "return", "self", ".", "_decode_cache", "[", "'body'", "]", "body", "=", "try_...
Return the Message Body. If auto_decode is enabled, the body will automatically be decoded using decode('utf-8') if possible. :rtype: bytes|str|unicode
[ "Return", "the", "Message", "Body", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/message.py#L53-L67
875
eandersson/amqpstorm
amqpstorm/message.py
Message.publish
def publish(self, routing_key, exchange='', mandatory=False, immediate=False): """Publish Message. :param str routing_key: Message routing key :param str exchange: The exchange to publish the message to :param bool mandatory: Requires the message is published :pa...
python
def publish(self, routing_key, exchange='', mandatory=False, immediate=False): return self._channel.basic.publish(body=self._body, routing_key=routing_key, exchange=exchange, ...
[ "def", "publish", "(", "self", ",", "routing_key", ",", "exchange", "=", "''", ",", "mandatory", "=", "False", ",", "immediate", "=", "False", ")", ":", "return", "self", ".", "_channel", ".", "basic", ".", "publish", "(", "body", "=", "self", ".", "...
Publish Message. :param str routing_key: Message routing key :param str exchange: The exchange to publish the message to :param bool mandatory: Requires the message is published :param bool immediate: Request immediate delivery :raises AMQPInvalidArgument: Invalid Parameters ...
[ "Publish", "Message", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/message.py#L149-L170
876
eandersson/amqpstorm
amqpstorm/message.py
Message._update_properties
def _update_properties(self, name, value): """Update properties, and keep cache up-to-date if auto decode is enabled. :param str name: Key :param obj value: Value :return: """ if self._auto_decode and 'properties' in self._decode_cache: self._decode_c...
python
def _update_properties(self, name, value): if self._auto_decode and 'properties' in self._decode_cache: self._decode_cache['properties'][name] = value self._properties[name] = value
[ "def", "_update_properties", "(", "self", ",", "name", ",", "value", ")", ":", "if", "self", ".", "_auto_decode", "and", "'properties'", "in", "self", ".", "_decode_cache", ":", "self", ".", "_decode_cache", "[", "'properties'", "]", "[", "name", "]", "=",...
Update properties, and keep cache up-to-date if auto decode is enabled. :param str name: Key :param obj value: Value :return:
[ "Update", "properties", "and", "keep", "cache", "up", "-", "to", "-", "date", "if", "auto", "decode", "is", "enabled", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/message.py#L344-L354
877
eandersson/amqpstorm
amqpstorm/message.py
Message._try_decode_utf8_content
def _try_decode_utf8_content(self, content, content_type): """Generic function to decode content. :param object content: :return: """ if not self._auto_decode or not content: return content if content_type in self._decode_cache: return self._decod...
python
def _try_decode_utf8_content(self, content, content_type): if not self._auto_decode or not content: return content if content_type in self._decode_cache: return self._decode_cache[content_type] if isinstance(content, dict): content = self._try_decode_dict(cont...
[ "def", "_try_decode_utf8_content", "(", "self", ",", "content", ",", "content_type", ")", ":", "if", "not", "self", ".", "_auto_decode", "or", "not", "content", ":", "return", "content", "if", "content_type", "in", "self", ".", "_decode_cache", ":", "return", ...
Generic function to decode content. :param object content: :return:
[ "Generic", "function", "to", "decode", "content", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/message.py#L356-L371
878
eandersson/amqpstorm
amqpstorm/message.py
Message._try_decode_dict
def _try_decode_dict(self, content): """Decode content of a dictionary. :param dict content: :return: """ result = dict() for key, value in content.items(): key = try_utf8_decode(key) if isinstance(value, dict): result[key] = self....
python
def _try_decode_dict(self, content): result = dict() for key, value in content.items(): key = try_utf8_decode(key) if isinstance(value, dict): result[key] = self._try_decode_dict(value) elif isinstance(value, list): result[key] = self._...
[ "def", "_try_decode_dict", "(", "self", ",", "content", ")", ":", "result", "=", "dict", "(", ")", "for", "key", ",", "value", "in", "content", ".", "items", "(", ")", ":", "key", "=", "try_utf8_decode", "(", "key", ")", "if", "isinstance", "(", "val...
Decode content of a dictionary. :param dict content: :return:
[ "Decode", "content", "of", "a", "dictionary", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/message.py#L373-L390
879
eandersson/amqpstorm
amqpstorm/message.py
Message._try_decode_list
def _try_decode_list(content): """Decode content of a list. :param list|tuple content: :return: """ result = list() for value in content: result.append(try_utf8_decode(value)) return result
python
def _try_decode_list(content): result = list() for value in content: result.append(try_utf8_decode(value)) return result
[ "def", "_try_decode_list", "(", "content", ")", ":", "result", "=", "list", "(", ")", "for", "value", "in", "content", ":", "result", ".", "append", "(", "try_utf8_decode", "(", "value", ")", ")", "return", "result" ]
Decode content of a list. :param list|tuple content: :return:
[ "Decode", "content", "of", "a", "list", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/message.py#L393-L402
880
eandersson/amqpstorm
amqpstorm/management/basic.py
Basic.get
def get(self, queue, virtual_host='/', requeue=False, to_dict=False, count=1, truncate=50000, encoding='auto'): """Get Messages. :param str queue: Queue name :param str virtual_host: Virtual host name :param bool requeue: Re-queue message :param bool to_dict: Should ...
python
def get(self, queue, virtual_host='/', requeue=False, to_dict=False, count=1, truncate=50000, encoding='auto'): ackmode = 'ack_requeue_false' if requeue: ackmode = 'ack_requeue_true' get_messages = json.dumps( { 'count': count, ...
[ "def", "get", "(", "self", ",", "queue", ",", "virtual_host", "=", "'/'", ",", "requeue", "=", "False", ",", "to_dict", "=", "False", ",", "count", "=", "1", ",", "truncate", "=", "50000", ",", "encoding", "=", "'auto'", ")", ":", "ackmode", "=", "...
Get Messages. :param str queue: Queue name :param str virtual_host: Virtual host name :param bool requeue: Re-queue message :param bool to_dict: Should incoming messages be converted to a dictionary before delivery. :param int count: How many message...
[ "Get", "Messages", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/management/basic.py#L45-L92
881
eandersson/amqpstorm
amqpstorm/management/virtual_host.py
VirtualHost.get
def get(self, virtual_host): """Get Virtual Host details. :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 """ virtu...
python
def get(self, virtual_host): virtual_host = quote(virtual_host, '') return self.http_client.get(API_VIRTUAL_HOST % virtual_host)
[ "def", "get", "(", "self", ",", "virtual_host", ")", ":", "virtual_host", "=", "quote", "(", "virtual_host", ",", "''", ")", "return", "self", ".", "http_client", ".", "get", "(", "API_VIRTUAL_HOST", "%", "virtual_host", ")" ]
Get Virtual Host details. :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
[ "Get", "Virtual", "Host", "details", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/management/virtual_host.py#L10-L21
882
eandersson/amqpstorm
amqpstorm/management/virtual_host.py
VirtualHost.create
def create(self, virtual_host): """Create a Virtual Host. :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 """ virtu...
python
def create(self, virtual_host): virtual_host = quote(virtual_host, '') return self.http_client.put(API_VIRTUAL_HOST % virtual_host)
[ "def", "create", "(", "self", ",", "virtual_host", ")", ":", "virtual_host", "=", "quote", "(", "virtual_host", ",", "''", ")", "return", "self", ".", "http_client", ".", "put", "(", "API_VIRTUAL_HOST", "%", "virtual_host", ")" ]
Create a Virtual Host. :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
[ "Create", "a", "Virtual", "Host", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/management/virtual_host.py#L33-L44
883
eandersson/amqpstorm
amqpstorm/management/virtual_host.py
VirtualHost.delete
def delete(self, virtual_host): """Delete a Virtual Host. :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 """ virtu...
python
def delete(self, virtual_host): virtual_host = quote(virtual_host, '') return self.http_client.delete(API_VIRTUAL_HOST % virtual_host)
[ "def", "delete", "(", "self", ",", "virtual_host", ")", ":", "virtual_host", "=", "quote", "(", "virtual_host", ",", "''", ")", "return", "self", ".", "http_client", ".", "delete", "(", "API_VIRTUAL_HOST", "%", "virtual_host", ")" ]
Delete a Virtual Host. :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
[ "Delete", "a", "Virtual", "Host", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/management/virtual_host.py#L46-L57
884
eandersson/amqpstorm
amqpstorm/management/virtual_host.py
VirtualHost.get_permissions
def get_permissions(self, virtual_host): """Get all Virtual hosts permissions. :raises ApiError: Raises if the remote server encountered an error. :raises ApiConnectionError: Raises if there was a connectivity issue. :rtype: dict """ virtual_host = quote(virtual_host, '...
python
def get_permissions(self, virtual_host): virtual_host = quote(virtual_host, '') return self.http_client.get(API_VIRTUAL_HOSTS_PERMISSION % ( virtual_host ))
[ "def", "get_permissions", "(", "self", ",", "virtual_host", ")", ":", "virtual_host", "=", "quote", "(", "virtual_host", ",", "''", ")", "return", "self", ".", "http_client", ".", "get", "(", "API_VIRTUAL_HOSTS_PERMISSION", "%", "(", "virtual_host", ")", ")" ]
Get all Virtual hosts permissions. :raises ApiError: Raises if the remote server encountered an error. :raises ApiConnectionError: Raises if there was a connectivity issue. :rtype: dict
[ "Get", "all", "Virtual", "hosts", "permissions", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/management/virtual_host.py#L59-L71
885
eandersson/amqpstorm
amqpstorm/base.py
BaseChannel.add_consumer_tag
def add_consumer_tag(self, tag): """Add a Consumer tag. :param str tag: Consumer tag. :return: """ if not is_string(tag): raise AMQPChannelError('consumer tag needs to be a string') if tag not in self._consumer_tags: self._consumer_tags.append(tag...
python
def add_consumer_tag(self, tag): if not is_string(tag): raise AMQPChannelError('consumer tag needs to be a string') if tag not in self._consumer_tags: self._consumer_tags.append(tag)
[ "def", "add_consumer_tag", "(", "self", ",", "tag", ")", ":", "if", "not", "is_string", "(", "tag", ")", ":", "raise", "AMQPChannelError", "(", "'consumer tag needs to be a string'", ")", "if", "tag", "not", "in", "self", ".", "_consumer_tags", ":", "self", ...
Add a Consumer tag. :param str tag: Consumer tag. :return:
[ "Add", "a", "Consumer", "tag", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/base.py#L123-L132
886
eandersson/amqpstorm
amqpstorm/base.py
BaseChannel.remove_consumer_tag
def remove_consumer_tag(self, tag=None): """Remove a Consumer tag. If no tag is specified, all all tags will be removed. :param str|None tag: Consumer tag. :return: """ if tag is not None: if tag in self._consumer_tags: self._consumer_tag...
python
def remove_consumer_tag(self, tag=None): if tag is not None: if tag in self._consumer_tags: self._consumer_tags.remove(tag) else: self._consumer_tags = []
[ "def", "remove_consumer_tag", "(", "self", ",", "tag", "=", "None", ")", ":", "if", "tag", "is", "not", "None", ":", "if", "tag", "in", "self", ".", "_consumer_tags", ":", "self", ".", "_consumer_tags", ".", "remove", "(", "tag", ")", "else", ":", "s...
Remove a Consumer tag. If no tag is specified, all all tags will be removed. :param str|None tag: Consumer tag. :return:
[ "Remove", "a", "Consumer", "tag", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/base.py#L134-L146
887
eandersson/amqpstorm
amqpstorm/base.py
BaseMessage.to_dict
def to_dict(self): """Message to Dictionary. :rtype: dict """ return { 'body': self._body, 'method': self._method, 'properties': self._properties, 'channel': self._channel }
python
def to_dict(self): return { 'body': self._body, 'method': self._method, 'properties': self._properties, 'channel': self._channel }
[ "def", "to_dict", "(", "self", ")", ":", "return", "{", "'body'", ":", "self", ".", "_body", ",", "'method'", ":", "self", ".", "_method", ",", "'properties'", ":", "self", ".", "_properties", ",", "'channel'", ":", "self", ".", "_channel", "}" ]
Message to Dictionary. :rtype: dict
[ "Message", "to", "Dictionary", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/base.py#L171-L181
888
eandersson/amqpstorm
amqpstorm/base.py
BaseMessage.to_tuple
def to_tuple(self): """Message to Tuple. :rtype: tuple """ return self._body, self._channel, self._method, self._properties
python
def to_tuple(self): return self._body, self._channel, self._method, self._properties
[ "def", "to_tuple", "(", "self", ")", ":", "return", "self", ".", "_body", ",", "self", ".", "_channel", ",", "self", ".", "_method", ",", "self", ".", "_properties" ]
Message to Tuple. :rtype: tuple
[ "Message", "to", "Tuple", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/base.py#L183-L188
889
eandersson/amqpstorm
amqpstorm/management/connection.py
Connection.close
def close(self, connection, reason='Closed via management api'): """Close Connection. :param str connection: Connection name :param str reason: Reason for closing connection. :raises ApiError: Raises if the remote server encountered an error. :raises ApiConnectionError: Raises ...
python
def close(self, connection, reason='Closed via management api'): close_payload = json.dumps({ 'name': connection, 'reason': reason }) connection = quote(connection, '') return self.http_client.delete(API_CONNECTION % connection, ...
[ "def", "close", "(", "self", ",", "connection", ",", "reason", "=", "'Closed via management api'", ")", ":", "close_payload", "=", "json", ".", "dumps", "(", "{", "'name'", ":", "connection", ",", "'reason'", ":", "reason", "}", ")", "connection", "=", "qu...
Close Connection. :param str connection: Connection name :param str reason: Reason for closing connection. :raises ApiError: Raises if the remote server encountered an error. :raises ApiConnectionError: Raises if there was a connectivity issue. :rtype: None
[ "Close", "Connection", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/management/connection.py#L32-L52
890
eandersson/amqpstorm
amqpstorm/rpc.py
Rpc.on_frame
def on_frame(self, frame_in): """On RPC Frame. :param specification.Frame frame_in: Amqp frame. :return: """ if frame_in.name not in self._request: return False uuid = self._request[frame_in.name] if self._response[uuid]: self._response[u...
python
def on_frame(self, frame_in): if frame_in.name not in self._request: return False uuid = self._request[frame_in.name] if self._response[uuid]: self._response[uuid].append(frame_in) else: self._response[uuid] = [frame_in] return True
[ "def", "on_frame", "(", "self", ",", "frame_in", ")", ":", "if", "frame_in", ".", "name", "not", "in", "self", ".", "_request", ":", "return", "False", "uuid", "=", "self", ".", "_request", "[", "frame_in", ".", "name", "]", "if", "self", ".", "_resp...
On RPC Frame. :param specification.Frame frame_in: Amqp frame. :return:
[ "On", "RPC", "Frame", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/rpc.py#L29-L43
891
eandersson/amqpstorm
amqpstorm/rpc.py
Rpc.register_request
def register_request(self, valid_responses): """Register a RPC request. :param list valid_responses: List of possible Responses that we should be waiting for. :return: """ uuid = str(uuid4()) self._response[uuid] = [] for acti...
python
def register_request(self, valid_responses): uuid = str(uuid4()) self._response[uuid] = [] for action in valid_responses: self._request[action] = uuid return uuid
[ "def", "register_request", "(", "self", ",", "valid_responses", ")", ":", "uuid", "=", "str", "(", "uuid4", "(", ")", ")", "self", ".", "_response", "[", "uuid", "]", "=", "[", "]", "for", "action", "in", "valid_responses", ":", "self", ".", "_request"...
Register a RPC request. :param list valid_responses: List of possible Responses that we should be waiting for. :return:
[ "Register", "a", "RPC", "request", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/rpc.py#L45-L56
892
eandersson/amqpstorm
amqpstorm/rpc.py
Rpc.get_request
def get_request(self, uuid, raw=False, multiple=False, connection_adapter=None): """Get a RPC request. :param str uuid: Rpc Identifier :param bool raw: If enabled return the frame as is, else return result as a dictionary. :param bool multipl...
python
def get_request(self, uuid, raw=False, multiple=False, connection_adapter=None): if uuid not in self._response: return self._wait_for_request( uuid, connection_adapter or self._default_connection_adapter ) frame = self._get_response_frame(uuid)...
[ "def", "get_request", "(", "self", ",", "uuid", ",", "raw", "=", "False", ",", "multiple", "=", "False", ",", "connection_adapter", "=", "None", ")", ":", "if", "uuid", "not", "in", "self", ".", "_response", ":", "return", "self", ".", "_wait_for_request...
Get a RPC request. :param str uuid: Rpc Identifier :param bool raw: If enabled return the frame as is, else return result as a dictionary. :param bool multiple: Are we expecting multiple frames. :param obj connection_adapter: Provide custom connection adapter. ...
[ "Get", "a", "RPC", "request", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/rpc.py#L86-L110
893
eandersson/amqpstorm
amqpstorm/rpc.py
Rpc._get_response_frame
def _get_response_frame(self, uuid): """Get a response frame. :param str uuid: Rpc Identifier :return: """ frame = None frames = self._response.get(uuid, None) if frames: frame = frames.pop(0) return frame
python
def _get_response_frame(self, uuid): frame = None frames = self._response.get(uuid, None) if frames: frame = frames.pop(0) return frame
[ "def", "_get_response_frame", "(", "self", ",", "uuid", ")", ":", "frame", "=", "None", "frames", "=", "self", ".", "_response", ".", "get", "(", "uuid", ",", "None", ")", "if", "frames", ":", "frame", "=", "frames", ".", "pop", "(", "0", ")", "ret...
Get a response frame. :param str uuid: Rpc Identifier :return:
[ "Get", "a", "response", "frame", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/rpc.py#L112-L122
894
eandersson/amqpstorm
amqpstorm/rpc.py
Rpc._wait_for_request
def _wait_for_request(self, uuid, connection_adapter=None): """Wait for RPC request to arrive. :param str uuid: Rpc Identifier. :param obj connection_adapter: Provide custom connection adapter. :return: """ start_time = time.time() while not self._response[uuid]:...
python
def _wait_for_request(self, uuid, connection_adapter=None): start_time = time.time() while not self._response[uuid]: connection_adapter.check_for_errors() if time.time() - start_time > self._timeout: self._raise_rpc_timeout_error(uuid) time.sleep(IDLE_...
[ "def", "_wait_for_request", "(", "self", ",", "uuid", ",", "connection_adapter", "=", "None", ")", ":", "start_time", "=", "time", ".", "time", "(", ")", "while", "not", "self", ".", "_response", "[", "uuid", "]", ":", "connection_adapter", ".", "check_for...
Wait for RPC request to arrive. :param str uuid: Rpc Identifier. :param obj connection_adapter: Provide custom connection adapter. :return:
[ "Wait", "for", "RPC", "request", "to", "arrive", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/rpc.py#L124-L136
895
eandersson/amqpstorm
amqpstorm/rpc.py
Rpc._raise_rpc_timeout_error
def _raise_rpc_timeout_error(self, uuid): """Gather information and raise an Rpc exception. :param str uuid: Rpc Identifier. :return: """ requests = [] for key, value in self._request.items(): if value == uuid: requests.append(key) sel...
python
def _raise_rpc_timeout_error(self, uuid): requests = [] for key, value in self._request.items(): if value == uuid: requests.append(key) self.remove(uuid) message = ( 'rpc requests %s (%s) took too long' % ( uuid, ...
[ "def", "_raise_rpc_timeout_error", "(", "self", ",", "uuid", ")", ":", "requests", "=", "[", "]", "for", "key", ",", "value", "in", "self", ".", "_request", ".", "items", "(", ")", ":", "if", "value", "==", "uuid", ":", "requests", ".", "append", "("...
Gather information and raise an Rpc exception. :param str uuid: Rpc Identifier. :return:
[ "Gather", "information", "and", "raise", "an", "Rpc", "exception", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/rpc.py#L138-L156
896
eandersson/amqpstorm
amqpstorm/compatibility.py
get_default_ssl_version
def get_default_ssl_version(): """Get the highest support TLS version, if none is available, return None. :rtype: bool|None """ if hasattr(ssl, 'PROTOCOL_TLSv1_2'): return ssl.PROTOCOL_TLSv1_2 elif hasattr(ssl, 'PROTOCOL_TLSv1_1'): return ssl.PROTOCOL_TLSv1_1 elif hasattr(ssl, '...
python
def get_default_ssl_version(): if hasattr(ssl, 'PROTOCOL_TLSv1_2'): return ssl.PROTOCOL_TLSv1_2 elif hasattr(ssl, 'PROTOCOL_TLSv1_1'): return ssl.PROTOCOL_TLSv1_1 elif hasattr(ssl, 'PROTOCOL_TLSv1'): return ssl.PROTOCOL_TLSv1 return None
[ "def", "get_default_ssl_version", "(", ")", ":", "if", "hasattr", "(", "ssl", ",", "'PROTOCOL_TLSv1_2'", ")", ":", "return", "ssl", ".", "PROTOCOL_TLSv1_2", "elif", "hasattr", "(", "ssl", ",", "'PROTOCOL_TLSv1_1'", ")", ":", "return", "ssl", ".", "PROTOCOL_TLS...
Get the highest support TLS version, if none is available, return None. :rtype: bool|None
[ "Get", "the", "highest", "support", "TLS", "version", "if", "none", "is", "available", "return", "None", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/compatibility.py#L44-L55
897
eandersson/amqpstorm
amqpstorm/compatibility.py
is_string
def is_string(obj): """Is this a string. :param object obj: :rtype: bool """ if PYTHON3: str_type = (bytes, str) else: str_type = (bytes, str, unicode) return isinstance(obj, str_type)
python
def is_string(obj): if PYTHON3: str_type = (bytes, str) else: str_type = (bytes, str, unicode) return isinstance(obj, str_type)
[ "def", "is_string", "(", "obj", ")", ":", "if", "PYTHON3", ":", "str_type", "=", "(", "bytes", ",", "str", ")", "else", ":", "str_type", "=", "(", "bytes", ",", "str", ",", "unicode", ")", "return", "isinstance", "(", "obj", ",", "str_type", ")" ]
Is this a string. :param object obj: :rtype: bool
[ "Is", "this", "a", "string", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/compatibility.py#L74-L84
898
eandersson/amqpstorm
amqpstorm/compatibility.py
is_integer
def is_integer(obj): """Is this an integer. :param object obj: :return: """ if PYTHON3: return isinstance(obj, int) return isinstance(obj, (int, long))
python
def is_integer(obj): if PYTHON3: return isinstance(obj, int) return isinstance(obj, (int, long))
[ "def", "is_integer", "(", "obj", ")", ":", "if", "PYTHON3", ":", "return", "isinstance", "(", "obj", ",", "int", ")", "return", "isinstance", "(", "obj", ",", "(", "int", ",", "long", ")", ")" ]
Is this an integer. :param object obj: :return:
[ "Is", "this", "an", "integer", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/compatibility.py#L87-L95
899
eandersson/amqpstorm
amqpstorm/compatibility.py
try_utf8_decode
def try_utf8_decode(value): """Try to decode an object. :param value: :return: """ if not value or not is_string(value): return value elif PYTHON3 and not isinstance(value, bytes): return value elif not PYTHON3 and not isinstance(value, unicode): return value tr...
python
def try_utf8_decode(value): if not value or not is_string(value): return value elif PYTHON3 and not isinstance(value, bytes): return value elif not PYTHON3 and not isinstance(value, unicode): return value try: return value.decode('utf-8') except UnicodeDecodeError: ...
[ "def", "try_utf8_decode", "(", "value", ")", ":", "if", "not", "value", "or", "not", "is_string", "(", "value", ")", ":", "return", "value", "elif", "PYTHON3", "and", "not", "isinstance", "(", "value", ",", "bytes", ")", ":", "return", "value", "elif", ...
Try to decode an object. :param value: :return:
[ "Try", "to", "decode", "an", "object", "." ]
38330906c0af19eea482f43c5ce79bab98a1e064
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/compatibility.py#L111-L129