Skip to content

Commit b4f396a

Browse files
committed
docstrs
1 parent b89c8ef commit b4f396a

File tree

1 file changed

+50
-1
lines changed

1 file changed

+50
-1
lines changed

mycroft/skills/intent_services/converse_service.py

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,19 @@ def __init__(self, bus):
1919

2020
@property
2121
def config(self):
22+
"""
23+
Returns:
24+
converse_config (dict): config for converse handling options
25+
"""
2226
return Configuration.get().get("skills", {}).get("converse") or {}
2327

2428
def get_active_skills(self):
29+
"""Active skill ids ordered by converse priority
30+
this represents the order in which converse will be called
31+
32+
Returns:
33+
active_skills (list): ordered list of skill_ids
34+
"""
2535
return [skill[0] for skill in self.active_skills]
2636

2737
def deactivate_skill(self, skill_id, source_skill=None):
@@ -71,6 +81,21 @@ def activate_skill(self, skill_id, source_skill=None):
7181
self._consecutive_activations[skill_id] += 1
7282

7383
def _activate_allowed(self, skill_id, source_skill=None):
84+
"""Checks if a skill_id is allowed to jump to the front of active skills list
85+
86+
- can a skill activate a different skill
87+
- is the skill blacklisted from conversing
88+
- is converse configured to only allow specific skills
89+
- did the skill activate too many times in a row
90+
91+
Args:
92+
skill_id (str): identifier of skill to be added.
93+
source_skill (str): skill requesting the removal
94+
95+
Returns:
96+
permitted (bool): True if skill can be activated
97+
"""
98+
7499
# cross activation control if skills can activate each other
75100
if not self.config.get("cross_activation"):
76101
source_skill = source_skill or skill_id
@@ -114,6 +139,17 @@ def _activate_allowed(self, skill_id, source_skill=None):
114139
return True
115140

116141
def _deactivate_allowed(self, skill_id, source_skill=None):
142+
"""Checks if a skill_id is allowed to be removed from active skills list
143+
144+
- can a skill deactivate a different skill
145+
146+
Args:
147+
skill_id (str): identifier of skill to be added.
148+
source_skill (str): skill requesting the removal
149+
150+
Returns:
151+
permitted (bool): True if skill can be deactivated
152+
"""
117153
# cross activation control if skills can deactivate each other
118154
if not self.config.get("cross_activation"):
119155
source_skill = source_skill or skill_id
@@ -123,7 +159,17 @@ def _deactivate_allowed(self, skill_id, source_skill=None):
123159
return True
124160

125161
def _converse_allowed(self, skill_id):
126-
""" check if skill_id is not blacklisted from using converse """
162+
"""Checks if a skill_id is allowed to converse
163+
164+
- is the skill blacklisted from conversing
165+
- is converse configured to only allow specific skills
166+
167+
Args:
168+
skill_id (str): identifier of skill that wants to converse.
169+
170+
Returns:
171+
permitted (bool): True if skill can converse
172+
"""
127173
opmode = self.config.get("converse_mode",
128174
ConverseMode.ACCEPT_ALL)
129175
if opmode == ConverseMode.BLACKLIST and skill_id in \
@@ -177,6 +223,9 @@ def converse(self, utterances, skill_id, lang, message):
177223
skill_id: skill to query.
178224
lang (str): current language
179225
message (Message): message containing interaction info.
226+
227+
Returns:
228+
handled (bool): True if handled otherwise False.
180229
"""
181230
if self._converse_allowed(skill_id):
182231
converse_msg = message.reply("skill.converse.request",

0 commit comments

Comments
 (0)