plugin XEP-0300: type hints
This commit is contained in:
parent
131096ed53
commit
1fd553db40
1 changed files with 18 additions and 14 deletions
|
|
@ -17,21 +17,24 @@
|
|||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from sat.core.i18n import _
|
||||
from typing import Tuple
|
||||
import base64
|
||||
from collections import OrderedDict
|
||||
import hashlib
|
||||
|
||||
from twisted.internet import threads
|
||||
from twisted.internet import defer
|
||||
from twisted.words.protocols.jabber.xmlstream import XMPPHandler
|
||||
from twisted.words.xish import domish
|
||||
from wokkel import disco, iwokkel
|
||||
from zope.interface import implementer
|
||||
|
||||
from sat.core import exceptions
|
||||
from sat.core.constants import Const as C
|
||||
from sat.core.i18n import _
|
||||
from sat.core.log import getLogger
|
||||
|
||||
log = getLogger(__name__)
|
||||
from sat.core import exceptions
|
||||
from twisted.words.xish import domish
|
||||
from twisted.words.protocols.jabber.xmlstream import XMPPHandler
|
||||
from twisted.internet import threads
|
||||
from twisted.internet import defer
|
||||
from zope.interface import implementer
|
||||
from wokkel import disco, iwokkel
|
||||
from collections import OrderedDict
|
||||
import hashlib
|
||||
import base64
|
||||
|
||||
|
||||
PLUGIN_INFO = {
|
||||
|
|
@ -61,6 +64,7 @@ class XEP_0300(object):
|
|||
("sha-512", hashlib.sha512),
|
||||
)
|
||||
)
|
||||
ALGO_DEFAULT = ALGO_DEFAULT
|
||||
|
||||
def __init__(self, host):
|
||||
log.info(_("plugin Hashes initialization"))
|
||||
|
|
@ -176,12 +180,12 @@ class XEP_0300(object):
|
|||
hash_elt["algo"] = algo
|
||||
return hash_elt
|
||||
|
||||
def parseHashElt(self, parent):
|
||||
def parseHashElt(self, parent: domish.Element) -> Tuple[str, bytes]:
|
||||
"""Find and parse a hash element
|
||||
|
||||
if multiple elements are found, the strongest managed one is returned
|
||||
@param (domish.Element): parent of <hash/> element
|
||||
@return (tuple[str, bytes]): (algo, hash) tuple
|
||||
@param parent: parent of <hash/> element
|
||||
@return: (algo, hash) tuple
|
||||
both values can be None if <hash/> is empty
|
||||
@raise exceptions.NotFound: the element is not present
|
||||
@raise exceptions.DataError: the element is invalid
|
||||
|
|
|
|||
Loading…
Reference in a new issue