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:
Goffi 2019-08-13 19:08:41 +02:00
commit fbfe96c505

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# SAT: a jabber client
@ -25,12 +25,13 @@ from sat.plugins import plugin_xep_0060
from sat.plugins import plugin_misc_text_syntaxes
from sat.tools.xml_tools import ElementParser
from wokkel.pubsub import NS_PUBSUB
import importlib
class XEP_0277Test(helpers.SatTestCase):
PUBSUB_ENTRY_1 = (
u"""
"""
<item id="c745a688-9b02-11e3-a1a3-c0143dd4fe51">
<entry xmlns="%s">
<title type="text">&lt;span&gt;titre&lt;/span&gt;</title>
@ -49,7 +50,7 @@ class XEP_0277Test(helpers.SatTestCase):
)
PUBSUB_ENTRY_2 = (
u"""
"""
<item id="c745a688-9b02-11e3-a1a3-c0143dd4fe51">
<entry xmlns='%s'>
<title type="text">&lt;div&gt;titre&lt;/div&gt;</title>
@ -81,7 +82,7 @@ class XEP_0277Test(helpers.SatTestCase):
self.host.plugins["XEP-0060"] = plugin_xep_0060.XEP_0060(self.host)
self.host.plugins["XEP-0163"] = XEP_0163(self.host)
reload(plugin_misc_text_syntaxes) # reload the plugin to avoid conflict error
importlib.reload(plugin_misc_text_syntaxes) # reload the plugin to avoid conflict error
self.host.plugins["TEXT_SYNTAXES"] = plugin_misc_text_syntaxes.TextSyntaxes(
self.host
)
@ -89,17 +90,17 @@ class XEP_0277Test(helpers.SatTestCase):
def test_item2mbdata_1(self):
expected = {
u"id": u"c745a688-9b02-11e3-a1a3-c0143dd4fe51",
u"atom_id": u"c745a688-9b02-11e3-a1a3-c0143dd4fe51",
u"title": u"<span>titre</span>",
u"updated": u"1392992199.0",
u"published": u"1392992198.0",
u"content": u"<p>contenu</p>texte sans balise<p>autre contenu</p>",
u"content_xhtml": u"<div><p>contenu</p>texte sans balise<p>autre contenu</p></div>",
u"author": u"test1@souliane.org",
"id": "c745a688-9b02-11e3-a1a3-c0143dd4fe51",
"atom_id": "c745a688-9b02-11e3-a1a3-c0143dd4fe51",
"title": "<span>titre</span>",
"updated": "1392992199.0",
"published": "1392992198.0",
"content": "<p>contenu</p>texte sans balise<p>autre contenu</p>",
"content_xhtml": "<div><p>contenu</p>texte sans balise<p>autre contenu</p></div>",
"author": "test1@souliane.org",
}
item_elt = (
ElementParser()(self.PUBSUB_ENTRY_1, namespace=NS_PUBSUB).elements().next()
next(ElementParser()(self.PUBSUB_ENTRY_1, namespace=NS_PUBSUB).elements())
)
d = self.plugin.item2mbdata(item_elt)
d.addCallback(self.assertEqual, expected)
@ -107,18 +108,18 @@ class XEP_0277Test(helpers.SatTestCase):
def test_item2mbdata_2(self):
expected = {
u"id": u"c745a688-9b02-11e3-a1a3-c0143dd4fe51",
u"atom_id": u"c745a688-9b02-11e3-a1a3-c0143dd4fe51",
u"title": u"<div>titre</div>",
u"title_xhtml": u'<div><div style="">titre</div></div>',
u"updated": u"1392992199.0",
u"published": u"1392992198.0",
u"content": u"<div><p>contenu</p>texte dans balise<p>autre contenu</p></div>",
u"content_xhtml": u"<div><p>contenu</p>texte dans balise<p>autre contenu</p></div>",
u"author": u"test1@souliane.org",
"id": "c745a688-9b02-11e3-a1a3-c0143dd4fe51",
"atom_id": "c745a688-9b02-11e3-a1a3-c0143dd4fe51",
"title": "<div>titre</div>",
"title_xhtml": '<div><div style="">titre</div></div>',
"updated": "1392992199.0",
"published": "1392992198.0",
"content": "<div><p>contenu</p>texte dans balise<p>autre contenu</p></div>",
"content_xhtml": "<div><p>contenu</p>texte dans balise<p>autre contenu</p></div>",
"author": "test1@souliane.org",
}
item_elt = (
ElementParser()(self.PUBSUB_ENTRY_2, namespace=NS_PUBSUB).elements().next()
next(ElementParser()(self.PUBSUB_ENTRY_2, namespace=NS_PUBSUB).elements())
)
d = self.plugin.item2mbdata(item_elt)
d.addCallback(self.assertEqual, expected)