Use get_registered_project instead of Project.load with exception handling

This commit is contained in:
Dominik Jain authored and Dominik Jain committed 2026-07-12 16:58:02 +02:00
1 parent 9bbbfea8d6
commit 45d4aaa20d
1 file changed
+4 -10
+4 -10
View File
@@ -1124,17 +1124,11 @@ class MemoryCommands(AutoRegisteringGroup):
exist at the configured location). Never auto-creates the ``.serena`` directory —
if no project configuration is found, the user is directed at ``serena project create``.
"""
from serena.project import Project
serena_config = SerenaConfig.from_config_file()
project_path = os.path.abspath(project)
try:
proj = Project.load(project_path, serena_config=serena_config, autogenerate=False)
except FileNotFoundError as e:
raise click.UsageError(
f"{e}\nNo Serena project found at {project_path}. Create one first with:\n serena project create {project_path}"
) from e
return proj.memory_manager
registered_project = serena_config.get_registered_project(project)
if registered_project is None:
raise click.UsageError(f"No Serena project found for '{project}'. Create one first.")
return registered_project.get_project_instance(serena_config).memory_manager
@staticmethod
@click.command(