Handle missing noise words file in CQS

This treats a None result from resolve_resource_file() as a FileNotFound
exception.
pull/3080/head
Åke Forslund 2021-12-17 16:53:42 +01:00 committed by Kris Gesling
parent 4791114609
commit 3fa99f288f
1 changed files with 8 additions and 4 deletions

View File

@ -68,11 +68,15 @@ class CommonQuerySkill(MycroftSkill, ABC):
noise_words_filename = resolve_resource_file(noise_words_filepath)
self.translated_noise_words = []
try:
with open(noise_words_filename) as f:
self.translated_noise_words = f.read().strip()
self.translated_noise_words = self.translated_noise_words.split()
if noise_words_filename:
with open(noise_words_filename) as f:
read_noise_words = f.read().strip()
self.translated_noise_words = read_noise_words.split()
else:
raise FileNotFoundError
except FileNotFoundError:
self.log.warning("Missing noise_words.list file in res/text/lang")
self.log.warning("Missing noise_words.list file in "
f"res/text/{self.lang}")
# these should probably be configurable
self.level_confidence = {