Skip to content

Commit

Permalink
Handle no plugin in Translator and Detector factory methods (#164)
Browse files Browse the repository at this point in the history
Add default libretranslate plugin to base requirements.txt
  • Loading branch information
NeonDaniel authored Nov 2, 2021
1 parent cdd8c8f commit fc546b2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
16 changes: 11 additions & 5 deletions neon_core/language/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
from neon_core.configuration import Configuration, get_private_keys
from ovos_plugin_manager.language import load_lang_detect_plugin, \
load_tx_plugin

import os

from neon_utils.configuration_utils import get_neon_lang_config
from ovos_plugin_manager.language import load_lang_detect_plugin, \
load_tx_plugin
from neon_utils.configuration_utils import get_neon_lang_config, LOG
from neon_core.configuration import Configuration, get_private_keys


def get_lang_config():
Expand Down Expand Up @@ -75,6 +76,9 @@ def create(module=None):
clazz = load_tx_plugin(module)
else:
clazz = TranslatorFactory.CLASSES.get(module)
if not clazz:
LOG.error(f"Configured translation module not found ({module})")
return None
config["keys"] = get_private_keys()
return clazz(config)

Expand All @@ -92,6 +96,8 @@ def create(module=None):
clazz = load_lang_detect_plugin(module)
else:
clazz = DetectorFactory.CLASSES.get(module)

if not clazz:
LOG.error(f"Configured detection module not found ({module})")
return None
config["keys"] = get_private_keys()
return clazz(config)
1 change: 1 addition & 0 deletions requirements/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ ovos-skills-manager>=0.0.2

# plugins
ovos-plugin-manager==0.0.1
neon-lang-plugin-libretranslate>=0.1.2

# text parser modules
RAKEkeywords>=0.2.0

0 comments on commit fc546b2

Please sign in to comment.