comparison sat/plugins/plugin_misc_watched.py @ 4037:524856bd7b19

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.
author Goffi <goffi@goffi.org>
date Sat, 08 Apr 2023 13:54:42 +0200
parents be6d91572633
children
comparison
equal deleted inserted replaced
4036:c4464d7ae97b 4037:524856bd7b19
59 ) 59 )
60 60
61 def __init__(self, host): 61 def __init__(self, host):
62 log.info(_("Watched initialisation")) 62 log.info(_("Watched initialisation"))
63 self.host = host 63 self.host = host
64 host.memory.updateParams(self.params) 64 host.memory.update_params(self.params)
65 host.trigger.add("presence_received", self._presenceReceivedTrigger) 65 host.trigger.add("presence_received", self._presence_received_trigger)
66 66
67 def _presenceReceivedTrigger(self, client, entity, show, priority, statuses): 67 def _presence_received_trigger(self, client, entity, show, priority, statuses):
68 if show == C.PRESENCE_UNAVAILABLE: 68 if show == C.PRESENCE_UNAVAILABLE:
69 return True 69 return True
70 70
71 # we check that the previous presence was unavailable (no notification else) 71 # we check that the previous presence was unavailable (no notification else)
72 try: 72 try:
73 old_show = self.host.memory.getEntityDatum( 73 old_show = self.host.memory.get_entity_datum(
74 client, entity, "presence").show 74 client, entity, "presence").show
75 except (KeyError, exceptions.UnknownEntityError): 75 except (KeyError, exceptions.UnknownEntityError):
76 old_show = C.PRESENCE_UNAVAILABLE 76 old_show = C.PRESENCE_UNAVAILABLE
77 77
78 if old_show == C.PRESENCE_UNAVAILABLE: 78 if old_show == C.PRESENCE_UNAVAILABLE:
79 watched = self.host.memory.getParamA( 79 watched = self.host.memory.param_get_a(
80 NAME, CATEGORY, profile_key=client.profile) 80 NAME, CATEGORY, profile_key=client.profile)
81 if entity in watched or entity.userhostJID() in watched: 81 if entity in watched or entity.userhostJID() in watched:
82 self.host.actionNew( 82 self.host.action_new(
83 { 83 {
84 "xmlui": xml_tools.note( 84 "xmlui": xml_tools.note(
85 _(NOTIF).format(entity=entity.full()) 85 _(NOTIF).format(entity=entity.full())
86 ).toXml() 86 ).toXml()
87 }, 87 },