Skip to content

Commit cb2e189

Browse files
Require toolnames to be a "packagename.filename" combination.
1 parent 5d4ece2 commit cb2e189

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/seclab_taskflow_agent/available_tools.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,14 @@ def get_tool(self, tooltype: AvailableToolType, toolname: str):
5555
return self.__yamlcache[tooltype][toolname]
5656
except KeyError:
5757
pass
58-
# Split the string to get the path and filename.
58+
# Split the string to get the package and filename.
5959
components = toolname.rsplit('.', 1)
60-
if len(components) == 2:
61-
path = components[0]
62-
filename = components[1]
63-
else:
64-
path = ''
65-
filename = toolname
60+
if len(components) != 2:
61+
raise BadToolNameError(f'Not a valid toolname: "{toolname}". It should be something like: "packagename.filename"')
62+
package = components[0]
63+
filename = components[1]
6664
try:
67-
d = importlib.resources.files(path)
65+
d = importlib.resources.files(package)
6866
if not d.is_dir():
6967
raise BadToolNameError(f'Cannot load {toolname} because {d} is not a valid directory.')
7068
f = d.joinpath(filename + ".yaml")

0 commit comments

Comments
 (0)