diff libervia/backend/plugins/plugin_xep_0071.py @ 4270:0d7bb4df2343

Reformatted code base using black.
author Goffi <goffi@goffi.org>
date Wed, 19 Jun 2024 18:44:57 +0200
parents 4b842c1fb686
children
line wrap: on
line diff
--- a/libervia/backend/plugins/plugin_xep_0071.py	Tue Jun 18 12:06:45 2024 +0200
+++ b/libervia/backend/plugins/plugin_xep_0071.py	Wed Jun 19 18:44:57 2024 +0200
@@ -114,6 +114,7 @@
         @param body_elts: XHTML-IM body elements found
         @return: the data with the extra parameter updated
         """
+
         # TODO: check if text only body is empty, then try to convert XHTML-IM to pure text and show a warning message
         def converted(xhtml, lang):
             if lang:
@@ -156,7 +157,7 @@
             defers.append(d)
 
     def _send_message_add_rich(self, data, client):
-        """ Construct XHTML-IM node and add it XML element
+        """Construct XHTML-IM node and add it XML element
 
         @param data: message data as sended by sendMessage callback
         """
@@ -197,8 +198,7 @@
         return d_list
 
     def message_received_trigger(self, client, message, post_treat):
-        """ Check presence of XHTML-IM in message
-        """
+        """Check presence of XHTML-IM in message"""
         try:
             html_elt = next(message.elements(NS_XHTML_IM, "html"))
         except StopIteration:
@@ -210,7 +210,7 @@
         return True
 
     def send_message_trigger(self, client, data, pre_xml_treatments, post_xml_treatments):
-        """ Check presence of rich text in extra """
+        """Check presence of rich text in extra"""
         rich = {}
         xhtml = {}
         for key, value in data["extra"].items():
@@ -231,7 +231,7 @@
         return True
 
     def _purge_style(self, styles_raw):
-        """ Remove unauthorised styles according to the XEP-0071
+        """Remove unauthorised styles according to the XEP-0071
         @param styles_raw: raw styles (value of the style attribute)
         """
         purged = []
@@ -250,7 +250,7 @@
         return "; ".join(["%s: %s" % data for data in purged])
 
     def XHTML2XHTML_IM(self, xhtml):
-        """ Convert XHTML document to XHTML_IM subset
+        """Convert XHTML document to XHTML_IM subset
         @param xhtml: raw xhtml to convert
         """
         # TODO: more clever tag replacement (replace forbidden tags with equivalents when possible)
@@ -275,7 +275,7 @@
                 attrib = elem.attrib
                 att_to_remove = set(attrib).difference(allowed[elem.tag])
                 for att in att_to_remove:
-                    del (attrib[att])
+                    del attrib[att]
                 if "style" in attrib:
                     attrib["style"] = self._purge_style(attrib["style"])