_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q259600 | VCard._process_rfc2425_record | validation | def _process_rfc2425_record(self,data):
"""Parse single RFC2425 record and update attributes of `self`.
:Parameters:
- `data`: the record (probably multiline)
:Types:
- `data`: `unicode`"""
label,value=data.split(":",1)
value=value.replace("\\n","\n").rep... | python | {
"resource": ""
} |
q259601 | VCard.rfc2426 | validation | def rfc2426(self):
"""Get the RFC2426 representation of `self`.
:return: the UTF-8 encoded RFC2426 representation.
:returntype: `str`"""
ret="begin:VCARD\r\n"
ret+="version:3.0\r\n"
for _unused, value in self.content.items():
if value is None:
... | python | {
"resource": ""
} |
q259602 | CacheItem.update_state | validation | def update_state(self):
"""Update current status of the item and compute time of the next
state change.
:return: the new state.
:returntype: :std:`datetime`"""
self._lock.acquire()
try:
now = datetime.utcnow()
if self.state == 'new':
... | python | {
"resource": ""
} |
q259603 | CacheFetcher._deactivate | validation | def _deactivate(self):
"""Remove the fetcher from cache and mark it not active."""
self.cache.remove_fetcher(self)
if self.active:
self._deactivated() | python | {
"resource": ""
} |
q259604 | CacheFetcher.got_it | validation | def got_it(self, value, state = "new"):
"""Handle a successfull retrieval and call apriopriate handler.
Should be called when retrieval succeeds.
Do nothing when the fetcher is not active any more (after
one of handlers was already called).
:Parameters:
- `value`: ... | python | {
"resource": ""
} |
q259605 | CacheFetcher.error | validation | def error(self, error_data):
"""Handle a retrieval error and call apriopriate handler.
Should be called when retrieval fails.
Do nothing when the fetcher is not active any more (after
one of handlers was already called).
:Parameters:
- `error_data`: additional info... | python | {
"resource": ""
} |
q259606 | CacheFetcher.timeout | validation | def timeout(self):
"""Handle fetcher timeout and call apriopriate handler.
Is called by the cache object and should _not_ be called by fetcher or
application.
Do nothing when the fetcher is not active any more (after
one of handlers was already called)."""
if not self.a... | python | {
"resource": ""
} |
q259607 | CacheFetcher._try_backup_item | validation | def _try_backup_item(self):
"""Check if a backup item is available in cache and call
the item handler if it is.
:return: `True` if backup item was found.
:returntype: `bool`"""
if not self._backup_state:
return False
item = self.cache.get_item(self.address, s... | python | {
"resource": ""
} |
q259608 | Cache.add_item | validation | def add_item(self, item):
"""Add an item to the cache.
Item state is updated before adding it (it will not be 'new' any more).
:Parameters:
- `item`: the item to add.
:Types:
- `item`: `CacheItem`
:return: state of the item after addition.
:retu... | python | {
"resource": ""
} |
q259609 | Cache.get_item | validation | def get_item(self, address, state = 'fresh'):
"""Get an item from the cache.
:Parameters:
- `address`: its address.
- `state`: the worst state that is acceptable.
:Types:
- `address`: any hashable
- `state`: `str`
:return: the item or `No... | python | {
"resource": ""
} |
q259610 | Cache.update_item | validation | def update_item(self, item):
"""Update state of an item in the cache.
Update item's state and remove the item from the cache
if its new state is 'purged'
:Parameters:
- `item`: item to update.
:Types:
- `item`: `CacheItem`
:return: new state of ... | python | {
"resource": ""
} |
q259611 | Cache.purge_items | validation | def purge_items(self):
"""Remove purged and overlimit items from the cache.
TODO: optimize somehow.
Leave no more than 75% of `self.max_items` items in the cache."""
self._lock.acquire()
try:
il=self._items_list
num_items = len(il)
need_remov... | python | {
"resource": ""
} |
q259612 | Cache.remove_fetcher | validation | def remove_fetcher(self, fetcher):
"""Remove a running fetcher from the list of active fetchers.
:Parameters:
- `fetcher`: fetcher instance.
:Types:
- `fetcher`: `CacheFetcher`"""
self._lock.acquire()
try:
for t, f in list(self._active_fetcher... | python | {
"resource": ""
} |
q259613 | Cache.set_fetcher | validation | def set_fetcher(self, fetcher_class):
"""Set the fetcher class.
:Parameters:
- `fetcher_class`: the fetcher class.
:Types:
- `fetcher_class`: `CacheFetcher` based class
"""
self._lock.acquire()
try:
self._fetcher = fetcher_class
... | python | {
"resource": ""
} |
q259614 | CacheSuite.register_fetcher | validation | def register_fetcher(self, object_class, fetcher_class):
"""Register a fetcher class for an object class.
:Parameters:
- `object_class`: class to be retrieved by the fetcher.
- `fetcher_class`: the fetcher class.
:Types:
- `object_class`: `classobj`
... | python | {
"resource": ""
} |
q259615 | CacheSuite.unregister_fetcher | validation | def unregister_fetcher(self, object_class):
"""Unregister a fetcher class for an object class.
:Parameters:
- `object_class`: class retrieved by the fetcher.
:Types:
- `object_class`: `classobj`
"""
self._lock.acquire()
try:
cache = se... | python | {
"resource": ""
} |
q259616 | _register_client_authenticator | validation | def _register_client_authenticator(klass, name):
"""Add a client authenticator class to `CLIENT_MECHANISMS_D`,
`CLIENT_MECHANISMS` and, optionally, to `SECURE_CLIENT_MECHANISMS`
"""
# pylint: disable-msg=W0212
CLIENT_MECHANISMS_D[name] = klass
items = sorted(CLIENT_MECHANISMS_D.items(), key = _k... | python | {
"resource": ""
} |
q259617 | _register_server_authenticator | validation | def _register_server_authenticator(klass, name):
"""Add a client authenticator class to `SERVER_MECHANISMS_D`,
`SERVER_MECHANISMS` and, optionally, to `SECURE_SERVER_MECHANISMS`
"""
# pylint: disable-msg=W0212
SERVER_MECHANISMS_D[name] = klass
items = sorted(SERVER_MECHANISMS_D.items(), key = _k... | python | {
"resource": ""
} |
q259618 | sasl_mechanism | validation | def sasl_mechanism(name, secure, preference = 50):
"""Class decorator generator for `ClientAuthenticator` or
`ServerAuthenticator` subclasses. Adds the class to the pyxmpp.sasl
mechanism registry.
:Parameters:
- `name`: SASL mechanism name
- `secure`: if the mechanims can be considered ... | python | {
"resource": ""
} |
q259619 | PasswordDatabase.check_password | validation | def check_password(self, username, password, properties):
"""Check the password validity.
Used by plain-text authentication mechanisms.
Default implementation: retrieve a "plain" password for the `username`
and `realm` using `self.get_password` and compare it with the password
... | python | {
"resource": ""
} |
q259620 | Reply.encode | validation | def encode(self):
"""Base64-encode the data contained in the reply when appropriate.
:return: encoded data.
:returntype: `unicode`
"""
if self.data is None:
return ""
elif not self.data:
return "="
else:
ret = standard_b64encod... | python | {
"resource": ""
} |
q259621 | SessionHandler.handle_authorized | validation | def handle_authorized(self, event):
"""Send session esteblishment request if the feature was advertised by
the server.
"""
stream = event.stream
if not stream:
return
if not stream.initiator:
return
if stream.features is None:
r... | python | {
"resource": ""
} |
q259622 | _decode_asn1_string | validation | def _decode_asn1_string(data):
"""Convert ASN.1 string to a Unicode string.
"""
if isinstance(data, BMPString):
return bytes(data).decode("utf-16-be")
else:
return bytes(data).decode("utf-8") | python | {
"resource": ""
} |
q259623 | CertificateData.display_name | validation | def display_name(self):
"""Get human-readable subject name derived from the SubjectName
or SubjectAltName field.
"""
if self.subject_name:
return u", ".join( [ u", ".join(
[ u"{0}={1}".format(k,v) for k, v in dn_tuple ] )
fo... | python | {
"resource": ""
} |
q259624 | CertificateData.verify_server | validation | def verify_server(self, server_name, srv_type = 'xmpp-client'):
"""Verify certificate for a server.
:Parameters:
- `server_name`: name of the server presenting the cerificate
- `srv_type`: service type requested, as used in the SRV record
:Types:
- `server_na... | python | {
"resource": ""
} |
q259625 | CertificateData.verify_jid_against_common_name | validation | def verify_jid_against_common_name(self, jid):
"""Return `True` if jid is listed in the certificate commonName.
:Parameters:
- `jid`: JID requested (domain part only)
:Types:
- `jid`: `JID`
:Returntype: `bool`
"""
if not self.common_names:
... | python | {
"resource": ""
} |
q259626 | CertificateData.verify_jid_against_srv_name | validation | def verify_jid_against_srv_name(self, jid, srv_type):
"""Check if the cerificate is valid for given domain-only JID
and a service type.
:Parameters:
- `jid`: JID requested (domain part only)
- `srv_type`: service type, e.g. 'xmpp-client'
:Types:
- `ji... | python | {
"resource": ""
} |
q259627 | CertificateData.verify_client | validation | def verify_client(self, client_jid = None, domains = None):
"""Verify certificate for a client.
Please note that `client_jid` is only a hint to choose from the names,
other JID may be returned if `client_jid` is not included in the
certificate.
:Parameters:
- `clien... | python | {
"resource": ""
} |
q259628 | BasicCertificateData.from_ssl_socket | validation | def from_ssl_socket(cls, ssl_socket):
"""Load certificate data from an SSL socket.
"""
cert = cls()
try:
data = ssl_socket.getpeercert()
except AttributeError:
# PyPy doesn't have .getppercert
return cert
logger.debug("Certificate data ... | python | {
"resource": ""
} |
q259629 | ASN1CertificateData.from_ssl_socket | validation | def from_ssl_socket(cls, ssl_socket):
"""Get certificate data from an SSL socket.
"""
try:
data = ssl_socket.getpeercert(True)
except AttributeError:
# PyPy doesn't have .getpeercert
data = None
if not data:
logger.debug("No certifi... | python | {
"resource": ""
} |
q259630 | ASN1CertificateData.from_der_data | validation | def from_der_data(cls, data):
"""Decode DER-encoded certificate.
:Parameters:
- `data`: the encoded certificate
:Types:
- `data`: `bytes`
:Return: decoded certificate data
:Returntype: ASN1CertificateData
"""
# pylint: disable=W0212
... | python | {
"resource": ""
} |
q259631 | ASN1CertificateData._decode_subject | validation | def _decode_subject(self, subject):
"""Load data from a ASN.1 subject.
"""
self.common_names = []
subject_name = []
for rdnss in subject:
for rdns in rdnss:
rdnss_list = []
for nameval in rdns:
val_type = nameval.get... | python | {
"resource": ""
} |
q259632 | ASN1CertificateData._decode_validity | validation | def _decode_validity(self, validity):
"""Load data from a ASN.1 validity value.
"""
not_after = validity.getComponentByName('notAfter')
not_after = str(not_after.getComponent())
if isinstance(not_after, GeneralizedTime):
self.not_after = datetime.strptime(not_after, "... | python | {
"resource": ""
} |
q259633 | ASN1CertificateData._decode_alt_names | validation | def _decode_alt_names(self, alt_names):
"""Load SubjectAltName from a ASN.1 GeneralNames value.
:Values:
- `alt_names`: the SubjectAltNama extension value
:Types:
- `alt_name`: `GeneralNames`
"""
for alt_name in alt_names:
tname = alt_name.get... | python | {
"resource": ""
} |
q259634 | ASN1CertificateData.from_file | validation | def from_file(cls, filename):
"""Load certificate from a file.
"""
with open(filename, "r") as pem_file:
data = pem.readPemFromFile(pem_file)
return cls.from_der_data(data) | python | {
"resource": ""
} |
q259635 | RosterTool.run | validation | def run(self):
"""Request client connection and start the main loop."""
if self.args.roster_cache and os.path.exists(self.args.roster_cache):
logging.info(u"Loading roster from {0!r}"
.format(self.args.roster_cache))
try:
... | python | {
"resource": ""
} |
q259636 | EventDispatcher.add_handler | validation | def add_handler(self, handler):
"""Add a handler object.
:Parameters:
- `handler`: the object providing event handler methods
:Types:
- `handler`: `EventHandler`
"""
if not isinstance(handler, EventHandler):
raise TypeError, "Not an EventHandl... | python | {
"resource": ""
} |
q259637 | EventDispatcher.remove_handler | validation | def remove_handler(self, handler):
"""Remove a handler object.
:Parameters:
- `handler`: the object to remove
"""
with self.lock:
if handler in self.handlers:
self.handlers.remove(handler)
self._update_handlers() | python | {
"resource": ""
} |
q259638 | EventDispatcher._update_handlers | validation | def _update_handlers(self):
"""Update `_handler_map` after `handlers` have been
modified."""
handler_map = defaultdict(list)
for i, obj in enumerate(self.handlers):
for dummy, handler in inspect.getmembers(obj, callable):
if not hasattr(handler, "_pyxmpp_event... | python | {
"resource": ""
} |
q259639 | EventDispatcher.dispatch | validation | def dispatch(self, block = False, timeout = None):
"""Get the next event from the queue and pass it to
the appropriate handlers.
:Parameters:
- `block`: wait for event if the queue is empty
- `timeout`: maximum time, in seconds, to wait if `block` is `True`
:Type... | python | {
"resource": ""
} |
q259640 | EventDispatcher.flush | validation | def flush(self, dispatch = True):
"""Read all events currently in the queue and dispatch them to the
handlers unless `dispatch` is `False`.
Note: If the queue contains `QUIT` the events after it won't be
removed.
:Parameters:
- `dispatch`: if the events should be ha... | python | {
"resource": ""
} |
q259641 | SCRAMClientAuthenticator.challenge | validation | def challenge(self, challenge):
"""Process a challenge and return the response.
:Parameters:
- `challenge`: the challenge from server.
:Types:
- `challenge`: `bytes`
:return: the response or a failure indicator.
:returntype: `sasl.Response` or `sasl.Fail... | python | {
"resource": ""
} |
q259642 | SCRAMClientAuthenticator._make_response | validation | def _make_response(self, nonce, salt, iteration_count):
"""Make a response for the first challenge from the server.
:return: the response or a failure indicator.
:returntype: `sasl.Response` or `sasl.Failure`
"""
self._salted_password = self.Hi(self.Normalize(self.password), sal... | python | {
"resource": ""
} |
q259643 | SCRAMClientAuthenticator._final_challenge | validation | def _final_challenge(self, challenge):
"""Process the second challenge from the server and return the
response.
:Parameters:
- `challenge`: the challenge from server.
:Types:
- `challenge`: `bytes`
:return: the response or a failure indicator.
:r... | python | {
"resource": ""
} |
q259644 | SCRAMClientAuthenticator.finish | validation | def finish(self, data):
"""Process success indicator from the server.
Process any addiitional data passed with the success.
Fail if the server was not authenticated.
:Parameters:
- `data`: an optional additional data with success.
:Types:
- `data`: `byte... | python | {
"resource": ""
} |
q259645 | feature_uri | validation | def feature_uri(uri):
"""Decorating attaching a feature URI (for Service Discovery or Capability
to a XMPPFeatureHandler class."""
def decorator(class_):
"""Returns a decorated class"""
if "_pyxmpp_feature_uris" not in class_.__dict__:
class_._pyxmpp_feature_uris = set()
... | python | {
"resource": ""
} |
q259646 | payload_element_name | validation | def payload_element_name(element_name):
"""Class decorator generator for decorationg
`StanzaPayload` subclasses.
:Parameters:
- `element_name`: XML element qname handled by the class
:Types:
- `element_name`: `unicode`
"""
def decorator(klass):
"""The payload_element_nam... | python | {
"resource": ""
} |
q259647 | stream_element_handler | validation | def stream_element_handler(element_name, usage_restriction = None):
"""Method decorator generator for decorating stream element
handler methods in `StreamFeatureHandler` subclasses.
:Parameters:
- `element_name`: stream element QName
- `usage_restriction`: optional usage restriction: "initi... | python | {
"resource": ""
} |
q259648 | Option._new_from_xml | validation | def _new_from_xml(cls, xmlnode):
"""Create a new `Option` object from an XML element.
:Parameters:
- `xmlnode`: the XML element.
:Types:
- `xmlnode`: `libxml2.xmlNode`
:return: the object created.
:returntype: `Option`
"""
label = from_ut... | python | {
"resource": ""
} |
q259649 | Field.add_option | validation | def add_option(self, value, label):
"""Add an option for the field.
:Parameters:
- `value`: option values.
- `label`: option label (human-readable description).
:Types:
- `value`: `list` of `unicode`
- `label`: `unicode`
"""
if typ... | python | {
"resource": ""
} |
q259650 | Field._new_from_xml | validation | def _new_from_xml(cls, xmlnode):
"""Create a new `Field` object from an XML element.
:Parameters:
- `xmlnode`: the XML element.
:Types:
- `xmlnode`: `libxml2.xmlNode`
:return: the object created.
:returntype: `Field`
"""
field_type = xmln... | python | {
"resource": ""
} |
q259651 | Item.add_field | validation | def add_field(self, name = None, values = None, field_type = None,
label = None, options = None, required = False, desc = None, value = None):
"""Add a field to the item.
:Parameters:
- `name`: field name.
- `values`: raw field values. Not to be used together with `v... | python | {
"resource": ""
} |
q259652 | Item._new_from_xml | validation | def _new_from_xml(cls, xmlnode):
"""Create a new `Item` object from an XML element.
:Parameters:
- `xmlnode`: the XML element.
:Types:
- `xmlnode`: `libxml2.xmlNode`
:return: the object created.
:returntype: `Item`
"""
child = xmlnode.chi... | python | {
"resource": ""
} |
q259653 | Form.add_item | validation | def add_item(self, fields = None):
"""Add and item to the form.
:Parameters:
- `fields`: fields of the item (they may be added later).
:Types:
- `fields`: `list` of `Field`
:return: the item added.
:returntype: `Item`
"""
item = Item(fiel... | python | {
"resource": ""
} |
q259654 | Form.make_submit | validation | def make_submit(self, keep_types = False):
"""Make a "submit" form using data in `self`.
Remove uneeded information from the form. The information removed
includes: title, instructions, field labels, fixed fields etc.
:raise ValueError: when any required field has no value.
:P... | python | {
"resource": ""
} |
q259655 | Form.__from_xml | validation | def __from_xml(self, xmlnode):
"""Initialize a `Form` object from an XML element.
:Parameters:
- `xmlnode`: the XML element.
:Types:
- `xmlnode`: `libxml2.xmlNode`
"""
self.fields = []
self.reported_fields = []
self.items = []
self... | python | {
"resource": ""
} |
q259656 | register_disco_cache_fetchers | validation | def register_disco_cache_fetchers(cache_suite,stream):
"""Register Service Discovery cache fetchers into given
cache suite and using the stream provided.
:Parameters:
- `cache_suite`: the cache suite where the fetchers are to be
registered.
- `stream`: the stream to be used by the... | python | {
"resource": ""
} |
q259657 | DiscoItem.remove | validation | def remove(self):
"""Remove `self` from the containing `DiscoItems` object."""
if self.disco is None:
return
self.xmlnode.unlinkNode()
oldns=self.xmlnode.ns()
ns=self.xmlnode.newNs(oldns.getContent(),None)
self.xmlnode.replaceNs(oldns,ns)
common_root.a... | python | {
"resource": ""
} |
q259658 | DiscoItem.set_node | validation | def set_node(self,node):
"""Set the node of the item.
:Parameters:
- `node`: the new node or `None`.
:Types:
- `node`: `unicode`
"""
if node is None:
if self.xmlnode.hasProp("node"):
self.xmlnode.unsetProp("node")
r... | python | {
"resource": ""
} |
q259659 | DiscoItem.set_action | validation | def set_action(self,action):
"""Set the action of the item.
:Parameters:
- `action`: the new action or `None`.
:Types:
- `action`: `unicode`
"""
if action is None:
if self.xmlnode.hasProp("action"):
self.xmlnode.unsetProp("acti... | python | {
"resource": ""
} |
q259660 | DiscoIdentity.get_name | validation | def get_name(self):
"""Get the name of the item.
:return: the name of the item or `None`.
:returntype: `unicode`"""
var = self.xmlnode.prop("name")
if not var:
var = ""
return var.decode("utf-8") | python | {
"resource": ""
} |
q259661 | DiscoIdentity.get_category | validation | def get_category(self):
"""Get the category of the item.
:return: the category of the item.
:returntype: `unicode`"""
var = self.xmlnode.prop("category")
if not var:
var = "?"
return var.decode("utf-8") | python | {
"resource": ""
} |
q259662 | DiscoIdentity.set_category | validation | def set_category(self, category):
"""Set the category of the item.
:Parameters:
- `category`: the new category.
:Types:
- `category`: `unicode` """
if not category:
raise ValueError("Category is required in DiscoIdentity")
category = unicode(c... | python | {
"resource": ""
} |
q259663 | DiscoIdentity.get_type | validation | def get_type(self):
"""Get the type of the item.
:return: the type of the item.
:returntype: `unicode`"""
item_type = self.xmlnode.prop("type")
if not item_type:
item_type = "?"
return item_type.decode("utf-8") | python | {
"resource": ""
} |
q259664 | DiscoIdentity.set_type | validation | def set_type(self, item_type):
"""Set the type of the item.
:Parameters:
- `item_type`: the new type.
:Types:
- `item_type`: `unicode` """
if not item_type:
raise ValueError("Type is required in DiscoIdentity")
item_type = unicode(item_type)
... | python | {
"resource": ""
} |
q259665 | DiscoItems.get_items | validation | def get_items(self):
"""Get the items contained in `self`.
:return: the items contained.
:returntype: `list` of `DiscoItem`"""
ret=[]
l=self.xpath_ctxt.xpathEval("d:item")
if l is not None:
for i in l:
ret.append(DiscoItem(self, i))
re... | python | {
"resource": ""
} |
q259666 | DiscoItems.add_item | validation | def add_item(self,jid,node=None,name=None,action=None):
"""Add a new item to the `DiscoItems` object.
:Parameters:
- `jid`: item JID.
- `node`: item node name.
- `name`: item name.
- `action`: action for a "disco push".
:Types:
- `jid`... | python | {
"resource": ""
} |
q259667 | DiscoItems.has_item | validation | def has_item(self,jid,node=None):
"""Check if `self` contains an item.
:Parameters:
- `jid`: JID of the item.
- `node`: node name of the item.
:Types:
- `jid`: `JID`
- `node`: `libxml2.xmlNode`
:return: `True` if the item is found in `sel... | python | {
"resource": ""
} |
q259668 | DiscoInfo.get_features | validation | def get_features(self):
"""Get the features contained in `self`.
:return: the list of features.
:returntype: `list` of `unicode`"""
l = self.xpath_ctxt.xpathEval("d:feature")
ret = []
for f in l:
if f.hasProp("var"):
ret.append( f.prop("var").... | python | {
"resource": ""
} |
q259669 | DiscoInfo.has_feature | validation | def has_feature(self,var):
"""Check if `self` contains the named feature.
:Parameters:
- `var`: the feature name.
:Types:
- `var`: `unicode`
:return: `True` if the feature is found in `self`.
:returntype: `bool`"""
if not var:
raise V... | python | {
"resource": ""
} |
q259670 | DiscoInfo.add_feature | validation | def add_feature(self,var):
"""Add a feature to `self`.
:Parameters:
- `var`: the feature name.
:Types:
- `var`: `unicode`"""
if self.has_feature(var):
return
n=self.xmlnode.newChild(None, "feature", None)
n.setProp("var", to_utf8(var)) | python | {
"resource": ""
} |
q259671 | DiscoInfo.remove_feature | validation | def remove_feature(self,var):
"""Remove a feature from `self`.
:Parameters:
- `var`: the feature name.
:Types:
- `var`: `unicode`"""
if not var:
raise ValueError("var is None")
if '"' not in var:
expr='d:feature[@var="%s"]' % (var,... | python | {
"resource": ""
} |
q259672 | DiscoInfo.get_identities | validation | def get_identities(self):
"""List the identity objects contained in `self`.
:return: the list of identities.
:returntype: `list` of `DiscoIdentity`"""
ret=[]
l=self.xpath_ctxt.xpathEval("d:identity")
if l is not None:
for i in l:
ret.append(Di... | python | {
"resource": ""
} |
q259673 | DiscoInfo.identity_is | validation | def identity_is(self,item_category,item_type=None):
"""Check if the item described by `self` belongs to the given category
and type.
:Parameters:
- `item_category`: the category name.
- `item_type`: the type name. If `None` then only the category is
checked... | python | {
"resource": ""
} |
q259674 | DiscoInfo.add_identity | validation | def add_identity(self,item_name,item_category=None,item_type=None):
"""Add an identity to the `DiscoInfo` object.
:Parameters:
- `item_name`: name of the item.
- `item_category`: category of the item.
- `item_type`: type of the item.
:Types:
- `it... | python | {
"resource": ""
} |
q259675 | DiscoCacheFetcherBase.fetch | validation | def fetch(self):
"""Initialize the Service Discovery process."""
from ..iq import Iq
jid,node = self.address
iq = Iq(to_jid = jid, stanza_type = "get")
disco = self.disco_class(node)
iq.add_content(disco.xmlnode)
self.stream.set_response_handlers(iq,self.__respons... | python | {
"resource": ""
} |
q259676 | DiscoCacheFetcherBase.__response | validation | def __response(self,stanza):
"""Handle successful disco response.
:Parameters:
- `stanza`: the stanza received.
:Types:
- `stanza`: `pyxmpp.stanza.Stanza`"""
try:
d=self.disco_class(stanza.get_query())
self.got_it(d)
except ValueEr... | python | {
"resource": ""
} |
q259677 | DiscoCacheFetcherBase.__error | validation | def __error(self,stanza):
"""Handle disco error response.
:Parameters:
- `stanza`: the stanza received.
:Types:
- `stanza`: `pyxmpp.stanza.Stanza`"""
try:
self.error(stanza.get_error())
except ProtocolError:
from ..error import Sta... | python | {
"resource": ""
} |
q259678 | Iq.make_error_response | validation | def make_error_response(self, cond):
"""Create error response for the a "get" or "set" iq stanza.
:Parameters:
- `cond`: error condition name, as defined in XMPP specification.
:return: new `Iq` object with the same "id" as self, "from" and "to"
attributes swapped, type... | python | {
"resource": ""
} |
q259679 | Iq.make_result_response | validation | def make_result_response(self):
"""Create result response for the a "get" or "set" iq stanza.
:return: new `Iq` object with the same "id" as self, "from" and "to"
attributes replaced and type="result".
:returntype: `Iq`"""
if self.stanza_type not in ("set", "get"):
... | python | {
"resource": ""
} |
q259680 | StreamTLSHandler._request_tls | validation | def _request_tls(self):
"""Request a TLS-encrypted connection.
[initiating entity only]"""
self.requested = True
element = ElementTree.Element(STARTTLS_TAG)
self.stream.write_element(element) | python | {
"resource": ""
} |
q259681 | StreamTLSHandler._make_tls_connection | validation | def _make_tls_connection(self):
"""Initiate TLS connection.
[initiating entity only]
"""
logger.debug("Preparing TLS connection")
if self.settings["tls_verify_peer"]:
cert_reqs = ssl.CERT_REQUIRED
else:
cert_reqs = ssl.CERT_NONE
self.strea... | python | {
"resource": ""
} |
q259682 | StreamTLSHandler.handle_tls_connected_event | validation | def handle_tls_connected_event(self, event):
"""Verify the peer certificate on the `TLSConnectedEvent`.
"""
if self.settings["tls_verify_peer"]:
valid = self.settings["tls_verify_callback"](event.stream,
event.peer_certificate)
... | python | {
"resource": ""
} |
q259683 | StreamTLSHandler.is_certificate_valid | validation | def is_certificate_valid(stream, cert):
"""Default certificate verification callback for TLS connections.
:Parameters:
- `cert`: certificate information
:Types:
- `cert`: `CertificateData`
:return: computed verification result.
"""
try:
... | python | {
"resource": ""
} |
q259684 | main | validation | def main():
"""Parse the command-line arguments and run the tool."""
parser = argparse.ArgumentParser(description = 'XMPP version checker',
parents = [XMPPSettings.get_arg_parser()])
parser.add_argument('source', metavar = 'SOURCE',
... | python | {
"resource": ""
} |
q259685 | VersionChecker.handle_authorized | validation | def handle_authorized(self, event):
"""Send the initial presence after log-in."""
request_software_version(self.client, self.target_jid,
self.success, self.failure) | python | {
"resource": ""
} |
q259686 | ExpiringDictionary.set_item | validation | def set_item(self, key, value, timeout = None, timeout_callback = None):
"""Set item of the dictionary.
:Parameters:
- `key`: the key.
- `value`: the object to store.
- `timeout`: timeout value for the object (in seconds from now).
- `timeout_callback`: f... | python | {
"resource": ""
} |
q259687 | ExpiringDictionary.expire | validation | def expire(self):
"""Do the expiration of dictionary items.
Remove items that expired by now from the dictionary.
:Return: time, in seconds, when the next item expires or `None`
:returntype: `float`
"""
with self._lock:
logger.debug("expdict.expire. timeouts... | python | {
"resource": ""
} |
q259688 | ExpiringDictionary._expire_item | validation | def _expire_item(self, key):
"""Do the expiration of a dictionary item.
Remove the item if it has expired by now.
:Parameters:
- `key`: key to the object.
:Types:
- `key`: any hashable value
"""
(timeout, callback) = self._timeouts[key]
n... | python | {
"resource": ""
} |
q259689 | Stanza._decode_attributes | validation | def _decode_attributes(self):
"""Decode attributes of the stanza XML element
and put them into the stanza properties."""
try:
from_jid = self._element.get('from')
if from_jid:
self._from_jid = JID(from_jid)
to_jid = self._element.get('to')
... | python | {
"resource": ""
} |
q259690 | Stanza._decode_error | validation | def _decode_error(self):
"""Decode error element of the stanza."""
error_qname = self._ns_prefix + "error"
for child in self._element:
if child.tag == error_qname:
self._error = StanzaErrorElement(child)
return
raise BadRequestProtocolError("Er... | python | {
"resource": ""
} |
q259691 | Stanza.set_payload | validation | def set_payload(self, payload):
"""Set stanza payload to a single item.
All current stanza content of will be dropped.
Marks the stanza dirty.
:Parameters:
- `payload`: XML element or stanza payload object to use
:Types:
- `payload`: :etree:`ElementTree.... | python | {
"resource": ""
} |
q259692 | Stanza.add_payload | validation | def add_payload(self, payload):
"""Add new the stanza payload.
Marks the stanza dirty.
:Parameters:
- `payload`: XML element or stanza payload object to add
:Types:
- `payload`: :etree:`ElementTree.Element` or `StanzaPayload`
"""
if self._payload... | python | {
"resource": ""
} |
q259693 | Stanza.get_all_payload | validation | def get_all_payload(self, specialize = False):
"""Return list of stanza payload objects.
:Parameters:
- `specialize`: If `True`, then return objects of specialized
`StanzaPayload` classes whenever possible, otherwise the
representation already available will be u... | python | {
"resource": ""
} |
q259694 | Stanza.get_payload | validation | def get_payload(self, payload_class, payload_key = None,
specialize = False):
"""Get the first payload item matching the given class
and optional key.
Payloads may be addressed using a specific payload class or
via the generic `XML... | python | {
"resource": ""
} |
q259695 | element_to_unicode | validation | def element_to_unicode(element):
"""Serialize an XML element into a unicode string.
This should work the same on Python2 and Python3 and with all
:etree:`ElementTree` implementations.
:Parameters:
- `element`: the XML element to serialize
:Types:
- `element`: :etree:`ElementTree.El... | python | {
"resource": ""
} |
q259696 | ResourceBindingHandler.bind | validation | def bind(self, stream, resource):
"""Bind to a resource.
[initiating entity only]
:Parameters:
- `resource`: the resource name to bind to.
:Types:
- `resource`: `unicode`
XMPP stream is authenticated for bare JID only. To use
the full JID it mus... | python | {
"resource": ""
} |
q259697 | ResourceBindingHandler._bind_success | validation | def _bind_success(self, stanza):
"""Handle resource binding success.
[initiating entity only]
:Parameters:
- `stanza`: <iq type="result"/> stanza received.
Set `streambase.StreamBase.me` to the full JID negotiated."""
# pylint: disable-msg=R0201
payload = s... | python | {
"resource": ""
} |
q259698 | serialize | validation | def serialize(element):
"""Serialize an XMPP element.
Utility function for debugging or logging.
:Parameters:
- `element`: the element to serialize
:Types:
- `element`: :etree:`ElementTree.Element`
:Return: serialized element
:Returntype: `unicode`
... | python | {
"resource": ""
} |
q259699 | XMPPSerializer.add_prefix | validation | def add_prefix(self, namespace, prefix):
"""Add a new namespace prefix.
If the root element has not yet been emitted the prefix will
be declared there, otherwise the prefix will be declared on the
top-most element using this namespace in every stanza.
:Parameters:
-... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.