massive refactoring to switch from camelCase to snake_case:
historically, Libervia (SàT before) was using camelCase as allowed by PEP8 when using a pre-PEP8 code, to use the same coding style as in Twisted. However, snake_case is more readable and it's better to follow PEP8 best practices, so it has been decided to move on full snake_case. Because Libervia has a huge codebase, this ended with a ugly mix of camelCase and snake_case. To fix that, this patch does a big refactoring by renaming every function and method (including bridge) that are not coming from Twisted or Wokkel, to use fully snake_case. This is a massive change, and may result in some bugs.
This commit is contained in:
parent
d50412c7f7
commit
6a6f15707a
1 changed files with 9945 additions and 9945 deletions
|
|
@ -94,19 +94,19 @@ class XEP_0071(object):
|
|||
log.info(_("XHTML-IM plugin initialization"))
|
||||
self.host = host
|
||||
self._s = self.host.plugins["TEXT_SYNTAXES"]
|
||||
self._s.addSyntax(
|
||||
self._s.add_syntax(
|
||||
self.SYNTAX_XHTML_IM,
|
||||
lambda xhtml: xhtml,
|
||||
self.XHTML2XHTML_IM,
|
||||
[self._s.OPT_HIDDEN],
|
||||
)
|
||||
host.trigger.add("messageReceived", self.messageReceivedTrigger)
|
||||
host.trigger.add("sendMessage", self.sendMessageTrigger)
|
||||
host.trigger.add("messageReceived", self.message_received_trigger)
|
||||
host.trigger.add("sendMessage", self.send_message_trigger)
|
||||
|
||||
def getHandler(self, client):
|
||||
def get_handler(self, client):
|
||||
return XEP_0071_handler(self)
|
||||
|
||||
def _messagePostTreat(self, data, message_elt, body_elts, client):
|
||||
def _message_post_treat(self, data, message_elt, body_elts, client):
|
||||
"""Callback which manage the post treatment of the message in case of XHTML-IM found
|
||||
|
||||
@param data: data send by messageReceived trigger through post_treat deferred
|
||||
|
|
@ -155,7 +155,7 @@ class XEP_0071(object):
|
|||
d.addCallback(self._fill_body_text, data, lang)
|
||||
defers.append(d)
|
||||
|
||||
def _sendMessageAddRich(self, data, client):
|
||||
def _send_message_add_rich(self, data, client):
|
||||
""" Construct XHTML-IM node and add it XML element
|
||||
|
||||
@param data: message data as sended by sendMessage callback
|
||||
|
|
@ -174,18 +174,18 @@ class XEP_0071(object):
|
|||
data["extra"]["xhtml"] = xhtml_im
|
||||
body_elt.addRawXml(xhtml_im)
|
||||
|
||||
syntax = self._s.getCurrentSyntax(client.profile)
|
||||
syntax = self._s.get_current_syntax(client.profile)
|
||||
defers = []
|
||||
if "xhtml" in data["extra"]:
|
||||
# we have directly XHTML
|
||||
for lang, xhtml in data_format.getSubDict("xhtml", data["extra"]):
|
||||
for lang, xhtml in data_format.get_sub_dict("xhtml", data["extra"]):
|
||||
self._check_body_text(data, lang, xhtml, self._s.SYNTAX_XHTML, defers)
|
||||
d = self._s.convert(xhtml, self._s.SYNTAX_XHTML, self.SYNTAX_XHTML_IM)
|
||||
d.addCallback(syntax_converted, lang)
|
||||
defers.append(d)
|
||||
elif "rich" in data["extra"]:
|
||||
# we have rich syntax to convert
|
||||
for lang, rich_data in data_format.getSubDict("rich", data["extra"]):
|
||||
for lang, rich_data in data_format.get_sub_dict("rich", data["extra"]):
|
||||
self._check_body_text(data, lang, rich_data, syntax, defers)
|
||||
d = self._s.convert(rich_data, syntax, self.SYNTAX_XHTML_IM)
|
||||
d.addCallback(syntax_converted, lang)
|
||||
|
|
@ -196,7 +196,7 @@ class XEP_0071(object):
|
|||
d_list.addCallback(lambda __: data)
|
||||
return d_list
|
||||
|
||||
def messageReceivedTrigger(self, client, message, post_treat):
|
||||
def message_received_trigger(self, client, message, post_treat):
|
||||
""" Check presence of XHTML-IM in message
|
||||
"""
|
||||
try:
|
||||
|
|
@ -206,10 +206,10 @@ class XEP_0071(object):
|
|||
pass
|
||||
else:
|
||||
body_elts = html_elt.elements(NS_XHTML, "body")
|
||||
post_treat.addCallback(self._messagePostTreat, message, body_elts, client)
|
||||
post_treat.addCallback(self._message_post_treat, message, body_elts, client)
|
||||
return True
|
||||
|
||||
def sendMessageTrigger(self, client, data, pre_xml_treatments, post_xml_treatments):
|
||||
def send_message_trigger(self, client, data, pre_xml_treatments, post_xml_treatments):
|
||||
""" Check presence of rich text in extra """
|
||||
rich = {}
|
||||
xhtml = {}
|
||||
|
|
@ -227,10 +227,10 @@ class XEP_0071(object):
|
|||
data["rich"] = rich
|
||||
else:
|
||||
data["xhtml"] = xhtml
|
||||
post_xml_treatments.addCallback(self._sendMessageAddRich, client)
|
||||
post_xml_treatments.addCallback(self._send_message_add_rich, client)
|
||||
return True
|
||||
|
||||
def _purgeStyle(self, styles_raw):
|
||||
def _purge_style(self, styles_raw):
|
||||
""" Remove unauthorised styles according to the XEP-0071
|
||||
@param styles_raw: raw styles (value of the style attribute)
|
||||
"""
|
||||
|
|
@ -277,7 +277,7 @@ class XEP_0071(object):
|
|||
for att in att_to_remove:
|
||||
del (attrib[att])
|
||||
if "style" in attrib:
|
||||
attrib["style"] = self._purgeStyle(attrib["style"])
|
||||
attrib["style"] = self._purge_style(attrib["style"])
|
||||
|
||||
for elem in to_strip:
|
||||
if elem.tag in blacklist:
|
||||
|
|
|
|||
Loading…
Reference in a new issue