Compare commits

...

3 Commits

Author SHA1 Message Date
Fabio Manganiello 47926290a2
[music.mopidy] Handle the case where `add` returns a list.
continuous-integration/drone/push Build is failing Details
2024-04-24 01:13:03 +02:00
Fabio Manganiello 71e32e4775
[tts.picovoice] Convert digits before replacing other substrings. 2024-04-24 00:49:04 +02:00
Fabio Manganiello 6b20c2083b
🐛 The `EventMatchResult` object shouldn't be initialized with `args` from the event.
If there's a good use-case for overriding `Event._matches_condition`
with a logic that also parses the event arguments, then those arguments
should be accessed directly from the event object, not from the match
result.

Initializing `EventMatchResult` with the arguments from the event means
that, if `EventMatchResult.parsed_args` are populated with custom
extracted arguments, then the upstream event arguments will also be
modified.

If the event is matched against multiple conditions, this will result in
the extracted tokens getting modified by each `matches_condition`
iteration.
2024-04-24 00:18:30 +02:00
3 changed files with 6 additions and 2 deletions

View File

@ -220,7 +220,7 @@ class Event(Message):
:param condition: The platypush.event.hook.EventCondition object
"""
result = EventMatchResult(is_match=False, parsed_args=self.args)
result = EventMatchResult(is_match=False)
match_scores = []
if not isinstance(self, condition.type):

View File

@ -255,6 +255,8 @@ class MusicMopidyPlugin(RunnablePlugin):
ret = self._add(resource, position=0)
if not ret:
self.logger.warning('Failed to add %s to the tracklist', resource)
elif isinstance(ret, list):
track_id = ret[0].get('tlid')
elif isinstance(ret, dict):
track_id = ret.get('tlid')
elif position is not None:

View File

@ -59,10 +59,12 @@ class TextConversionUtils:
@classmethod
def convert(cls, text: str) -> str:
text = cls._convert_digits(text)
for pattern, replacement in TextConversionUtils._conversions_map:
text = pattern.sub(replacement, text)
return cls._convert_digits(text)
return text
class TtsPicovoicePlugin(TtsPlugin):