Add input error checking. Intersection between valid tools and input tools should not be the null set
@@ -1101,6 +1101,11 @@ def is_openeye_installed(oetools=('oechem', 'oequacpac', 'oeiupac', 'oeomega')):
# Cast oetools to tuple if its a single string
if type(oetools) is str:
oetools = (oetools,)
+ tool_set = set(oetools)
+ valid_tool_set = set(tool_keys)
+ if tool_set & valid_tool_set == set():
+ # Check for empty set intersection
+ raise ValueError
try:
for tool in oetools:
if tool in tool_keys:
@@ -1109,6 +1114,9 @@ def is_openeye_installed(oetools=('oechem', 'oequacpac', 'oeiupac', 'oeomega')):
# Check that we have the license
if not getattr(module, tools_license[tool])():
raise ImportError
+ except ValueError:
+ raise ValueError("Expected OpenEye tools to have at least of the following {}, "
+ "but instead got {}".format(tool_keys, oetools))
except ImportError:
return False
return True
