mirror of
https://github.com/correl/SleekXMPP.git
synced 2024-11-23 19:19:53 +00:00
Update the API docs for XMLStream
This commit is contained in:
parent
a85891c611
commit
8922e2050a
5 changed files with 389 additions and 383 deletions
|
@ -1,13 +0,0 @@
|
||||||
=========
|
|
||||||
xmlstream
|
|
||||||
=========
|
|
||||||
|
|
||||||
.. module:: sleekxmpp.xmlstream
|
|
||||||
|
|
||||||
.. autoclass:: XMLStream
|
|
||||||
:members:
|
|
||||||
|
|
||||||
.. toctree::
|
|
||||||
|
|
||||||
stanzabase
|
|
||||||
tostring
|
|
10
docs/api/xmlstream/xmlstream.rst
Normal file
10
docs/api/xmlstream/xmlstream.rst
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
==========
|
||||||
|
XML Stream
|
||||||
|
==========
|
||||||
|
|
||||||
|
.. module:: sleekxmpp.xmlstream.xmlstream
|
||||||
|
|
||||||
|
.. autoexception:: RestartStream
|
||||||
|
|
||||||
|
.. autoclass:: XMLStream
|
||||||
|
:members:
|
|
@ -116,10 +116,29 @@ API Reference
|
||||||
api/xmlstream/stanzabase
|
api/xmlstream/stanzabase
|
||||||
api/xmlstream/handler
|
api/xmlstream/handler
|
||||||
api/xmlstream/matcher
|
api/xmlstream/matcher
|
||||||
|
api/xmlstream/xmlstream
|
||||||
api/xmlstream/scheduler
|
api/xmlstream/scheduler
|
||||||
api/xmlstream/tostring
|
api/xmlstream/tostring
|
||||||
api/xmlstream/filesocket
|
api/xmlstream/filesocket
|
||||||
|
|
||||||
|
Core Stanzas
|
||||||
|
~~~~~~~~~~~~
|
||||||
|
.. toctree::
|
||||||
|
:maxdepth: 2
|
||||||
|
|
||||||
|
api/stanza/rootstanza
|
||||||
|
api/stanza/message
|
||||||
|
api/stanza/presence
|
||||||
|
api/stanza/iq
|
||||||
|
api/stanza/error
|
||||||
|
api/stanza/stream_error
|
||||||
|
|
||||||
|
Plugins
|
||||||
|
~~~~~~~
|
||||||
|
.. toctree::
|
||||||
|
:maxdepth: 2
|
||||||
|
|
||||||
|
|
||||||
Additional Info
|
Additional Info
|
||||||
---------------
|
---------------
|
||||||
.. toctree::
|
.. toctree::
|
||||||
|
|
|
@ -30,66 +30,59 @@ class MatchXMLMask(MatcherBase):
|
||||||
XML pattern, or mask. For example, message stanzas with body elements
|
XML pattern, or mask. For example, message stanzas with body elements
|
||||||
could be matched using the mask:
|
could be matched using the mask:
|
||||||
|
|
||||||
|
.. code-block:: xml
|
||||||
|
|
||||||
<message xmlns="jabber:client"><body /></message>
|
<message xmlns="jabber:client"><body /></message>
|
||||||
|
|
||||||
Use of XMLMask is discouraged, and XPath or StanzaPath should be used
|
Use of XMLMask is discouraged, and
|
||||||
instead.
|
:class:`~sleekxmpp.xmlstream.matcher.xpath.MatchXPath` or
|
||||||
|
:class:`~sleekxmpp.xmlstream.matcher.stanzapath.StanzaPath`
|
||||||
|
should be used instead.
|
||||||
|
|
||||||
The use of namespaces in the mask comparison is controlled by
|
The use of namespaces in the mask comparison is controlled by
|
||||||
IGNORE_NS. Setting IGNORE_NS to True will disable namespace based matching
|
``IGNORE_NS``. Setting ``IGNORE_NS`` to ``True`` will disable namespace
|
||||||
for ALL XMLMask matchers.
|
based matching for ALL XMLMask matchers.
|
||||||
|
|
||||||
Methods:
|
:param criteria: Either an :class:`~xml.etree.ElementTree.Element` XML
|
||||||
match -- Overrides MatcherBase.match.
|
object or XML string to use as a mask.
|
||||||
setDefaultNS -- Set the default namespace for the mask.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, criteria):
|
def __init__(self, criteria):
|
||||||
"""
|
|
||||||
Create a new XMLMask matcher.
|
|
||||||
|
|
||||||
Arguments:
|
|
||||||
criteria -- Either an XML object or XML string to use as a mask.
|
|
||||||
"""
|
|
||||||
MatcherBase.__init__(self, criteria)
|
MatcherBase.__init__(self, criteria)
|
||||||
if isinstance(criteria, str):
|
if isinstance(criteria, str):
|
||||||
self._criteria = ET.fromstring(self._criteria)
|
self._criteria = ET.fromstring(self._criteria)
|
||||||
self.default_ns = 'jabber:client'
|
self.default_ns = 'jabber:client'
|
||||||
|
|
||||||
def setDefaultNS(self, ns):
|
def setDefaultNS(self, ns):
|
||||||
"""
|
"""Set the default namespace to use during comparisons.
|
||||||
Set the default namespace to use during comparisons.
|
|
||||||
|
|
||||||
Arguments:
|
:param ns: The new namespace to use as the default.
|
||||||
ns -- The new namespace to use as the default.
|
|
||||||
"""
|
"""
|
||||||
self.default_ns = ns
|
self.default_ns = ns
|
||||||
|
|
||||||
def match(self, xml):
|
def match(self, xml):
|
||||||
"""
|
"""Compare a stanza object or XML object against the stored XML mask.
|
||||||
Compare a stanza object or XML object against the stored XML mask.
|
|
||||||
|
|
||||||
Overrides MatcherBase.match.
|
Overrides MatcherBase.match.
|
||||||
|
|
||||||
Arguments:
|
:param xml: The stanza object or XML object to compare against.
|
||||||
xml -- The stanza object or XML object to compare against.
|
|
||||||
"""
|
"""
|
||||||
if hasattr(xml, 'xml'):
|
if hasattr(xml, 'xml'):
|
||||||
xml = xml.xml
|
xml = xml.xml
|
||||||
return self._mask_cmp(xml, self._criteria, True)
|
return self._mask_cmp(xml, self._criteria, True)
|
||||||
|
|
||||||
def _mask_cmp(self, source, mask, use_ns=False, default_ns='__no_ns__'):
|
def _mask_cmp(self, source, mask, use_ns=False, default_ns='__no_ns__'):
|
||||||
"""
|
"""Compare an XML object against an XML mask.
|
||||||
Compare an XML object against an XML mask.
|
|
||||||
|
|
||||||
Arguments:
|
:param source: The :class:`~xml.etree.ElementTree.Element` XML object
|
||||||
source -- The XML object to compare against the mask.
|
to compare against the mask.
|
||||||
mask -- The XML object serving as the mask.
|
:param mask: The :class:`~xml.etree.ElementTree.Element` XML object
|
||||||
use_ns -- Indicates if namespaces should be respected during
|
serving as the mask.
|
||||||
the comparison.
|
:param use_ns: Indicates if namespaces should be respected during
|
||||||
default_ns -- The default namespace to apply to elements that
|
the comparison.
|
||||||
do not have a specified namespace.
|
:default_ns: The default namespace to apply to elements that
|
||||||
Defaults to "__no_ns__".
|
do not have a specified namespace.
|
||||||
|
Defaults to ``"__no_ns__"``.
|
||||||
"""
|
"""
|
||||||
use_ns = not IGNORE_NS
|
use_ns = not IGNORE_NS
|
||||||
|
|
||||||
|
@ -148,14 +141,13 @@ class MatchXMLMask(MatcherBase):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _get_child(self, xml, tag):
|
def _get_child(self, xml, tag):
|
||||||
"""
|
"""Return a child element given its tag, ignoring namespace values.
|
||||||
Return a child element given its tag, ignoring namespace values.
|
|
||||||
|
|
||||||
Returns None if the child was not found.
|
Returns ``None`` if the child was not found.
|
||||||
|
|
||||||
Arguments:
|
:param xml: The :class:`~xml.etree.ElementTree.Element` XML object
|
||||||
xml -- The XML object to search for the given child tag.
|
to search for the given child tag.
|
||||||
tag -- The name of the subelement to find.
|
:param tag: The name of the subelement to find.
|
||||||
"""
|
"""
|
||||||
tag = tag.split('}')[-1]
|
tag = tag.split('}')[-1]
|
||||||
try:
|
try:
|
||||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue