Reformatted code base using black.
This commit is contained in:
parent
56319cbad3
commit
53fdaa9d09
1 changed files with 12604 additions and 8966 deletions
|
|
@ -114,6 +114,7 @@ class XEP_0071(object):
|
|||
@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 @@ class XEP_0071(object):
|
|||
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 @@ class XEP_0071(object):
|
|||
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 @@ class XEP_0071(object):
|
|||
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 @@ class XEP_0071(object):
|
|||
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 @@ class XEP_0071(object):
|
|||
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 @@ class XEP_0071(object):
|
|||
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"])
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue