Python 3 port:
/!\ this is a huge commit /!\ starting from this commit, SàT is needs Python 3.6+ /!\ SàT maybe be instable or some feature may not work anymore, this will improve with time This patch port backend, bridge and frontends to Python 3. Roughly this has been done this way: - 2to3 tools has been applied (with python 3.7) - all references to python2 have been replaced with python3 (notably shebangs) - fixed files not handled by 2to3 (notably the shell script) - several manual fixes - fixed issues reported by Python 3 that where not handled in Python 2 - replaced "async" with "async_" when needed (it's a reserved word from Python 3.7) - replaced zope's "implements" with @implementer decorator - temporary hack to handle data pickled in database, as str or bytes may be returned, to be checked later - fixed hash comparison for password - removed some code which is not needed anymore with Python 3 - deactivated some code which needs to be checked (notably certificate validation) - tested with jp, fixed reported issues until some basic commands worked - ported Primitivus (after porting dependencies like urwid satext) - more manual fixes
This commit is contained in:
parent
d21a6a660f
commit
fbfe96c505
1 changed files with 6336 additions and 6398 deletions
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python2
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# SAT plugin for Bookmarks (xep-0048)
|
||||
|
|
@ -74,7 +74,7 @@ class XEP_0048(object):
|
|||
in_sign="sss",
|
||||
out_sign="a{sa{sa{ss}}}",
|
||||
method=self._bookmarksList,
|
||||
async=True,
|
||||
async_=True,
|
||||
)
|
||||
host.bridge.addMethod(
|
||||
"bookmarksRemove",
|
||||
|
|
@ -82,7 +82,7 @@ class XEP_0048(object):
|
|||
in_sign="ssss",
|
||||
out_sign="",
|
||||
method=self._bookmarksRemove,
|
||||
async=True,
|
||||
async_=True,
|
||||
)
|
||||
host.bridge.addMethod(
|
||||
"bookmarksAdd",
|
||||
|
|
@ -90,7 +90,7 @@ class XEP_0048(object):
|
|||
in_sign="ssa{ss}ss",
|
||||
out_sign="",
|
||||
method=self._bookmarksAdd,
|
||||
async=True,
|
||||
async_=True,
|
||||
)
|
||||
try:
|
||||
self.private_plg = self.host.plugins["XEP-0049"]
|
||||
|
|
@ -115,7 +115,7 @@ class XEP_0048(object):
|
|||
|
||||
for bookmarks in (local, private, pubsub):
|
||||
if bookmarks is not None:
|
||||
for (room_jid, data) in bookmarks[XEP_0048.MUC_TYPE].items():
|
||||
for (room_jid, data) in list(bookmarks[XEP_0048.MUC_TYPE].items()):
|
||||
if data.get("autojoin", "false") == "true":
|
||||
nick = data.get("nick", client.jid.user)
|
||||
self.host.plugins["XEP-0045"].join(client, room_jid, nick, {})
|
||||
|
|
@ -196,8 +196,8 @@ class XEP_0048(object):
|
|||
if conference_elt.hasAttribute(attr):
|
||||
data[attr] = conference_elt[attr]
|
||||
try:
|
||||
data["nick"] = unicode(
|
||||
conference_elt.elements(NS_BOOKMARKS, "nick").next()
|
||||
data["nick"] = str(
|
||||
next(conference_elt.elements(NS_BOOKMARKS, "nick"))
|
||||
)
|
||||
except StopIteration:
|
||||
pass
|
||||
|
|
@ -264,7 +264,7 @@ class XEP_0048(object):
|
|||
d = self.host.plugins["XEP-0045"].join(client, room_jid, nick, {})
|
||||
|
||||
def join_eb(failure):
|
||||
log.warning(u"Error while trying to join room: {}".format(failure))
|
||||
log.warning("Error while trying to join room: {}".format(failure))
|
||||
# FIXME: failure are badly managed in plugin XEP-0045. Plugin XEP-0045 need to be fixed before managing errors correctly here
|
||||
return {}
|
||||
|
||||
|
|
@ -292,12 +292,12 @@ class XEP_0048(object):
|
|||
if bookmarks is None:
|
||||
continue
|
||||
for (room_jid, data) in sorted(
|
||||
bookmarks[XEP_0048.MUC_TYPE].items(),
|
||||
list(bookmarks[XEP_0048.MUC_TYPE].items()),
|
||||
key=lambda item: item[1].get("name", item[0].user),
|
||||
):
|
||||
room_jid_s = room_jid.full()
|
||||
adv_list.setRowIndex(
|
||||
u"%s %s" % (room_jid_s, data.get("nick") or client.jid.user)
|
||||
"%s %s" % (room_jid_s, data.get("nick") or client.jid.user)
|
||||
)
|
||||
xmlui.addText(data.get("name", ""))
|
||||
xmlui.addJid(room_jid)
|
||||
|
|
@ -354,7 +354,7 @@ class XEP_0048(object):
|
|||
@param profile_key: %(doc_profile_key)s
|
||||
"""
|
||||
assert storage_type in ("auto", "pubsub", "private", "local")
|
||||
if type_ == XEP_0048.URL_TYPE and {"autojoin", "nick"}.intersection(data.keys()):
|
||||
if type_ == XEP_0048.URL_TYPE and {"autojoin", "nick"}.intersection(list(data.keys())):
|
||||
raise ValueError("autojoin or nick can't be used with URLs")
|
||||
client = self.host.getClient(profile_key)
|
||||
if storage_type == "auto":
|
||||
|
|
|
|||
Loading…
Reference in a new issue