comparison sat/plugins/plugin_misc_watched.py @ 2624:56f94936df1e

code style reformatting using black
author Goffi <goffi@goffi.org>
date Wed, 27 Jun 2018 20:14:46 +0200
parents 26edcf3a30eb
children 003b8b4b56a7
comparison
equal deleted inserted replaced
2623:49533de4540b 2624:56f94936df1e
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. 18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 19
20 from sat.core.i18n import _, D_ 20 from sat.core.i18n import _, D_
21 from sat.core.constants import Const as C 21 from sat.core.constants import Const as C
22 from sat.core.log import getLogger 22 from sat.core.log import getLogger
23
23 log = getLogger(__name__) 24 log = getLogger(__name__)
24 from sat.core import exceptions 25 from sat.core import exceptions
25 from sat.tools import xml_tools 26 from sat.tools import xml_tools
26 27
27 28
31 C.PI_TYPE: "Misc", 32 C.PI_TYPE: "Misc",
32 C.PI_PROTOCOLS: [], 33 C.PI_PROTOCOLS: [],
33 C.PI_DEPENDENCIES: [], 34 C.PI_DEPENDENCIES: [],
34 C.PI_MAIN: "Watched", 35 C.PI_MAIN: "Watched",
35 C.PI_HANDLER: "no", 36 C.PI_HANDLER: "no",
36 C.PI_DESCRIPTION: _("""Watch for entities presence, and send notification accordingly""") 37 C.PI_DESCRIPTION: _(
38 """Watch for entities presence, and send notification accordingly"""
39 ),
37 } 40 }
38 41
39 42
40 CATEGORY = D_("Misc") 43 CATEGORY = D_("Misc")
41 NAME = "Watched" 44 NAME = "Watched"
49 <category name="{category_name}" label="{category_label}"> 52 <category name="{category_name}" label="{category_label}">
50 <param name="{name}" label="{label}" type="jids_list" security="0" /> 53 <param name="{name}" label="{label}" type="jids_list" security="0" />
51 </category> 54 </category>
52 </individual> 55 </individual>
53 </params> 56 </params>
54 """.format(category_name=CATEGORY, 57 """.format(
55 category_label=_(CATEGORY), 58 category_name=CATEGORY, category_label=_(CATEGORY), name=NAME, label=_(NAME)
56 name=NAME, 59 )
57 label=_(NAME),
58 )
59 60
60 def __init__(self, host): 61 def __init__(self, host):
61 log.info(_("Watched initialisation")) 62 log.info(_("Watched initialisation"))
62 self.host = host 63 self.host = host
63 host.memory.updateParams(self.params) 64 host.memory.updateParams(self.params)
74 old_show = C.PRESENCE_UNAVAILABLE 75 old_show = C.PRESENCE_UNAVAILABLE
75 76
76 if old_show == C.PRESENCE_UNAVAILABLE: 77 if old_show == C.PRESENCE_UNAVAILABLE:
77 watched = self.host.memory.getParamA(NAME, CATEGORY, profile_key=profile) 78 watched = self.host.memory.getParamA(NAME, CATEGORY, profile_key=profile)
78 if entity in watched or entity.userhostJID() in watched: 79 if entity in watched or entity.userhostJID() in watched:
79 self.host.actionNew({'xmlui': xml_tools.note(_(NOTIF).format(entity=entity.full())).toXml()}, profile=profile) 80 self.host.actionNew(
81 {
82 "xmlui": xml_tools.note(
83 _(NOTIF).format(entity=entity.full())
84 ).toXml()
85 },
86 profile=profile,
87 )
80 88
81 return True 89 return True