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
|
|
@ -48,7 +48,7 @@ PLUGIN_INFO = {
|
|||
D_(
|
||||
"""\
|
||||
Frontends can use HINT_* constants in mess_data['extra'] in a serialized 'hints' dict.
|
||||
Internal plugins can use directly addHint([HINT_* constant]).
|
||||
Internal plugins can use directly add_hint([HINT_* constant]).
|
||||
Will set mess_data['extra']['history'] to 'skipped' when no store is requested and message is not saved in history."""
|
||||
)
|
||||
),
|
||||
|
|
@ -67,13 +67,13 @@ class XEP_0334(object):
|
|||
def __init__(self, host):
|
||||
log.info(_("Message Processing Hints plugin initialization"))
|
||||
self.host = host
|
||||
host.trigger.add("sendMessage", self.sendMessageTrigger)
|
||||
host.trigger.add("messageReceived", self.messageReceivedTrigger, priority=-1000)
|
||||
host.trigger.add("sendMessage", self.send_message_trigger)
|
||||
host.trigger.add("messageReceived", self.message_received_trigger, priority=-1000)
|
||||
|
||||
def getHandler(self, client):
|
||||
def get_handler(self, client):
|
||||
return XEP_0334_handler()
|
||||
|
||||
def addHint(self, mess_data, hint):
|
||||
def add_hint(self, mess_data, hint):
|
||||
if hint == self.HINT_NO_COPY and not mess_data["to"].resource:
|
||||
log.error(
|
||||
"{hint} can only be used with full jids! Ignoring it.".format(hint=hint)
|
||||
|
|
@ -85,7 +85,7 @@ class XEP_0334(object):
|
|||
else:
|
||||
log.error("Unknown hint: {}".format(hint))
|
||||
|
||||
def addHintElements(self, message_elt: domish.Element, hints: Iterable[str]) -> None:
|
||||
def add_hint_elements(self, message_elt: domish.Element, hints: Iterable[str]) -> None:
|
||||
"""Add hints elements to message stanza
|
||||
|
||||
@param message_elt: stanza where hints must be added
|
||||
|
|
@ -97,27 +97,27 @@ class XEP_0334(object):
|
|||
else:
|
||||
log.debug('Not adding {hint!r} hint: it is already present in <message>')
|
||||
|
||||
def _sendPostXmlTreatment(self, mess_data):
|
||||
def _send_post_xml_treatment(self, mess_data):
|
||||
if "hints" in mess_data:
|
||||
self.addHintElements(mess_data["xml"], mess_data["hints"])
|
||||
self.add_hint_elements(mess_data["xml"], mess_data["hints"])
|
||||
return mess_data
|
||||
|
||||
def sendMessageTrigger(
|
||||
def send_message_trigger(
|
||||
self, client, mess_data, pre_xml_treatments, post_xml_treatments
|
||||
):
|
||||
"""Add the hints element to the message to be sent"""
|
||||
if "hints" in mess_data["extra"]:
|
||||
for hint in data_format.dict2iter("hints", mess_data["extra"], pop=True):
|
||||
self.addHint(hint)
|
||||
self.add_hint(hint)
|
||||
|
||||
post_xml_treatments.addCallback(self._sendPostXmlTreatment)
|
||||
post_xml_treatments.addCallback(self._send_post_xml_treatment)
|
||||
return True
|
||||
|
||||
def _receivedSkipHistory(self, mess_data):
|
||||
def _received_skip_history(self, mess_data):
|
||||
mess_data["history"] = C.HISTORY_SKIP
|
||||
return mess_data
|
||||
|
||||
def messageReceivedTrigger(self, client, message_elt, post_treat):
|
||||
def message_received_trigger(self, client, message_elt, post_treat):
|
||||
"""Check for hints in the received message"""
|
||||
for elt in message_elt.elements():
|
||||
if elt.uri == NS_HINTS and elt.name in (
|
||||
|
|
@ -125,7 +125,7 @@ class XEP_0334(object):
|
|||
self.HINT_NO_STORE,
|
||||
):
|
||||
log.debug("history will be skipped for this message, as requested")
|
||||
post_treat.addCallback(self._receivedSkipHistory)
|
||||
post_treat.addCallback(self._received_skip_history)
|
||||
break
|
||||
return True
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue