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
|
|
@ -102,17 +102,17 @@ class XEP_0184(object):
|
|||
self._dictRequest = dict()
|
||||
|
||||
# parameter value is retrieved before each use
|
||||
host.memory.updateParams(self.params)
|
||||
host.memory.update_params(self.params)
|
||||
|
||||
host.trigger.add("sendMessage", self.sendMessageTrigger)
|
||||
host.bridge.addSignal(
|
||||
"messageState", ".plugin", signature="sss"
|
||||
host.trigger.add("sendMessage", self.send_message_trigger)
|
||||
host.bridge.add_signal(
|
||||
"message_state", ".plugin", signature="sss"
|
||||
) # message_uid, status, profile
|
||||
|
||||
def getHandler(self, client):
|
||||
def get_handler(self, client):
|
||||
return XEP_0184_handler(self, client.profile)
|
||||
|
||||
def sendMessageTrigger(
|
||||
def send_message_trigger(
|
||||
self, client, mess_data, pre_xml_treatments, post_xml_treatments
|
||||
):
|
||||
"""Install SendMessage command hook """
|
||||
|
|
@ -121,7 +121,7 @@ class XEP_0184(object):
|
|||
message = mess_data["xml"]
|
||||
message_type = message.getAttribute("type")
|
||||
|
||||
if self._isActif(client.profile) and (
|
||||
if self._is_actif(client.profile) and (
|
||||
message_type == "chat" or message_type == "normal"
|
||||
):
|
||||
message.addElement("request", NS_MESSAGE_DELIVERY_RECEIPTS)
|
||||
|
|
@ -129,7 +129,7 @@ class XEP_0184(object):
|
|||
msg_id = message.getAttribute("id")
|
||||
self._dictRequest[msg_id] = uid
|
||||
reactor.callLater(
|
||||
TEMPO_DELETE_WAITING_ACK_S, self._clearDictRequest, msg_id
|
||||
TEMPO_DELETE_WAITING_ACK_S, self._clear_dict_request, msg_id
|
||||
)
|
||||
log.debug(
|
||||
_(
|
||||
|
|
@ -144,13 +144,13 @@ class XEP_0184(object):
|
|||
post_xml_treatments.addCallback(treatment)
|
||||
return True
|
||||
|
||||
def onMessageDeliveryReceiptsRequest(self, msg_elt, client):
|
||||
def on_message_delivery_receipts_request(self, msg_elt, client):
|
||||
"""This method is called on message delivery receipts **request** (XEP-0184 #7)
|
||||
@param msg_elt: message element
|
||||
@param client: %(doc_client)s"""
|
||||
from_jid = jid.JID(msg_elt["from"])
|
||||
|
||||
if self._isActif(client.profile) and client.roster.isSubscribedFrom(from_jid):
|
||||
if self._is_actif(client.profile) and client.roster.is_subscribed_from(from_jid):
|
||||
received_elt_ret = domish.Element((NS_MESSAGE_DELIVERY_RECEIPTS, "received"))
|
||||
try:
|
||||
received_elt_ret["id"] = msg_elt["id"]
|
||||
|
|
@ -162,7 +162,7 @@ class XEP_0184(object):
|
|||
msg_result_elt.addChild(received_elt_ret)
|
||||
client.send(msg_result_elt)
|
||||
|
||||
def onMessageDeliveryReceiptsReceived(self, msg_elt, client):
|
||||
def on_message_delivery_receipts_received(self, msg_elt, client):
|
||||
"""This method is called on message delivery receipts **received** (XEP-0184 #7)
|
||||
@param msg_elt: message element
|
||||
@param client: %(doc_client)s"""
|
||||
|
|
@ -173,7 +173,7 @@ class XEP_0184(object):
|
|||
try:
|
||||
uid = self._dictRequest[msg_id]
|
||||
del self._dictRequest[msg_id]
|
||||
self.host.bridge.messageState(
|
||||
self.host.bridge.message_state(
|
||||
uid, STATUS_MESSAGE_DELIVERY_RECEIVED, client.profile
|
||||
)
|
||||
log.debug(
|
||||
|
|
@ -182,7 +182,7 @@ class XEP_0184(object):
|
|||
except KeyError:
|
||||
pass
|
||||
|
||||
def _clearDictRequest(self, msg_id):
|
||||
def _clear_dict_request(self, msg_id):
|
||||
try:
|
||||
del self._dictRequest[msg_id]
|
||||
log.debug(
|
||||
|
|
@ -195,8 +195,8 @@ class XEP_0184(object):
|
|||
except KeyError:
|
||||
pass
|
||||
|
||||
def _isActif(self, profile):
|
||||
return self.host.memory.getParamA(PARAM_NAME, PARAM_KEY, profile_key=profile)
|
||||
def _is_actif(self, profile):
|
||||
return self.host.memory.param_get_a(PARAM_NAME, PARAM_KEY, profile_key=profile)
|
||||
|
||||
|
||||
@implementer(iwokkel.IDisco)
|
||||
|
|
@ -210,23 +210,23 @@ class XEP_0184_handler(XMPPHandler):
|
|||
def connectionInitialized(self):
|
||||
self.xmlstream.addObserver(
|
||||
MSG_CHAT_MESSAGE_DELIVERY_RECEIPTS_REQUEST,
|
||||
self.plugin_parent.onMessageDeliveryReceiptsRequest,
|
||||
self.plugin_parent.on_message_delivery_receipts_request,
|
||||
client=self.parent,
|
||||
)
|
||||
self.xmlstream.addObserver(
|
||||
MSG_CHAT_MESSAGE_DELIVERY_RECEIPTS_RECEIVED,
|
||||
self.plugin_parent.onMessageDeliveryReceiptsReceived,
|
||||
self.plugin_parent.on_message_delivery_receipts_received,
|
||||
client=self.parent,
|
||||
)
|
||||
|
||||
self.xmlstream.addObserver(
|
||||
MSG_NORMAL_MESSAGE_DELIVERY_RECEIPTS_REQUEST,
|
||||
self.plugin_parent.onMessageDeliveryReceiptsRequest,
|
||||
self.plugin_parent.on_message_delivery_receipts_request,
|
||||
client=self.parent,
|
||||
)
|
||||
self.xmlstream.addObserver(
|
||||
MSG_NORMAL_MESSAGE_DELIVERY_RECEIPTS_RECEIVED,
|
||||
self.plugin_parent.onMessageDeliveryReceiptsReceived,
|
||||
self.plugin_parent.on_message_delivery_receipts_received,
|
||||
client=self.parent,
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue