Skip to content
This repository has been archived by the owner on Oct 24, 2021. It is now read-only.

Commit

Permalink
refactor/config_kwarg_continued (#47)
Browse files Browse the repository at this point in the history
Co-authored-by: jarbasal <[email protected]>
  • Loading branch information
JarbasAl and JarbasAl authored Mar 2, 2021
1 parent 7c0c711 commit 847f0aa
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions ovos_utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ def resolve_resource_file(res_name, root_path=None, config=None):
Args:
res_name (str): a resource path/name
config (dict): mycroft.conf, to read data directory from
Returns:
str: path to resource or None if no resource found
"""
Expand Down
4 changes: 2 additions & 2 deletions ovos_utils/plugins/tts.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,10 @@ def __init__(self, lang, config, validator, audio_ext='wav',
self.spellings = self.load_spellings()
self.tts_name = type(self).__name__

def load_spellings(self):
def load_spellings(self, config=None):
"""Load phonetic spellings of words as dictionary."""
path = join('text', self.lang.lower(), 'phonetic_spellings.txt')
spellings_file = resolve_resource_file(path)
spellings_file = resolve_resource_file(path, config=config)
if not spellings_file:
return {}
try:
Expand Down
13 changes: 9 additions & 4 deletions ovos_utils/signal.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def get_ipc_directory(domain=None, config=None):
Args:
domain (str): The IPC domain. Basically a subdirectory to prevent
overlapping signal filenames.
config (dict): mycroft.conf, to read ipc directory from
Returns:
str: a path to the IPC directory
Expand Down Expand Up @@ -75,22 +76,24 @@ def create_file(filename):
f.write('')


def create_signal(signal_name):
def create_signal(signal_name, config=None):
"""Create a named signal
Args:
signal_name (str): The signal's name. Must only contain characters
valid in filenames.
config (dict): mycroft.conf, to read ipc directory from
"""
try:
path = os.path.join(get_ipc_directory(), "signal", signal_name)
path = os.path.join(get_ipc_directory(config=config),
"signal", signal_name)
create_file(path)
return os.path.isfile(path)
except IOError:
return False


def check_for_signal(signal_name, sec_lifetime=0):
def check_for_signal(signal_name, sec_lifetime=0, config=None):
"""See if a named signal exists
Args:
Expand All @@ -99,11 +102,13 @@ def check_for_signal(signal_name, sec_lifetime=0):
sec_lifetime (int, optional): How many seconds the signal should
remain valid. If 0 or not specified, it is a single-use signal.
If -1, it never expires.
config (dict): mycroft.conf, to read ipc directory from
Returns:
bool: True if the signal is defined, False otherwise
"""
path = os.path.join(get_ipc_directory(), "signal", signal_name)
path = os.path.join(get_ipc_directory(config=config),
"signal", signal_name)
if os.path.isfile(path):
if sec_lifetime == 0:
# consume this single-use signal
Expand Down

0 comments on commit 847f0aa

Please sign in to comment.