From 7a94973317bf01fe904282a9917a318efaeb0c1e Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Sat, 10 Aug 2024 15:45:31 +0430 Subject: [PATCH] doc : ENGINE_TYPE_ERROR added --- nava/functions.py | 4 +++- nava/params.py | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/nava/functions.py b/nava/functions.py index f1054ef..231c885 100644 --- a/nava/functions.py +++ b/nava/functions.py @@ -7,7 +7,7 @@ from functools import wraps from .thread import NavaThread from .params import OVERVIEW, Engine -from .params import SOUND_FILE_PLAY_ERROR, SOUND_FILE_EXIST_ERROR +from .params import SOUND_FILE_PLAY_ERROR, SOUND_FILE_EXIST_ERROR, ENGINE_TYPE_ERROR from .params import SOUND_FILE_PATH_TYPE_ERROR, SOUND_ID_EXIST_ERROR, LOOP_ASYNC_ERROR from .errors import NavaBaseError from . import params @@ -284,6 +284,8 @@ def play(sound_path, async_mode=False, loop=False, engine=Engine.AUTO): :type engine: Engine enum :return: None or sound id """ + if not isinstance(engine, Engine): + raise NavaBaseError(ENGINE_TYPE_ERROR) if loop and not async_mode: raise NavaBaseError(LOOP_ASYNC_ERROR) try: diff --git a/nava/params.py b/nava/params.py index 2efc6fe..111600c 100644 --- a/nava/params.py +++ b/nava/params.py @@ -27,6 +27,7 @@ class Engine(Enum): SOUND_FILE_PATH_TYPE_ERROR = "Sound file's path should be a string." SOUND_ID_EXIST_ERROR = "Given sound id doesn't exist." LOOP_ASYNC_ERROR = "`loop` can not be set True when `async_mode` is False." +ENGINE_TYPE_ERROR = "`engine` type must be `Engine` enum." _play_threads_map = dict() _play_threads_counter = 0