diff --git a/glotaran/project/project_registry.py b/glotaran/project/project_registry.py index b1e6fc9b1..38988adb8 100644 --- a/glotaran/project/project_registry.py +++ b/glotaran/project/project_registry.py @@ -98,11 +98,11 @@ def load_item(self, name: str) -> Any: ValueError Raise if the item does not exist. """ - try: - path = next(p for p in self._directory.iterdir() if name in p.name) - except StopIteration as e: - raise ValueError(f"No Item with name '{name}' exists.") from e - return self._loader(path) + if name in self.items: + return self._loader(self.items[name]) + raise ValueError( + f"No Item with name '{name}' exists. Known items are: {self.items.keys()}" + ) def markdown(self, join_indentation: int = 0) -> MarkdownStr: """Format the registry items as a markdown text.