Files
alfred/agent/tools/filesystem.py
T
francwa 2c8cdd3ab1 New archi: domain driven development
Working but need to check out code
2025-12-01 07:10:03 +01:00

60 lines
1.6 KiB
Python

"""Filesystem tools - Adapted for DDD architecture."""
from typing import Dict, Any
# Import use cases
from application.filesystem import SetFolderPathUseCase, ListFolderUseCase
# Import infrastructure
from infrastructure.filesystem import FileManager
from infrastructure.persistence.memory import Memory
def set_path_for_folder(memory: Memory, folder_name: str, path_value: str) -> Dict[str, Any]:
"""
Set a path in the configuration.
Args:
memory: Memory instance to store the configuration
folder_name: Name of folder to set (download, tvshow, movie, torrent)
path_value: Absolute path to the folder
Returns:
Dict with status or error information
"""
# Create file manager
file_manager = FileManager(memory)
# Create use case
use_case = SetFolderPathUseCase(file_manager)
# Execute use case
response = use_case.execute(folder_name, path_value)
# Return as dict
return response.to_dict()
def list_folder(memory: Memory, folder_type: str, path: str = ".") -> Dict[str, Any]:
"""
List contents of a folder.
Args:
memory: Memory instance to retrieve the configuration
folder_type: Type of folder to list (download, tvshow, movie, torrent)
path: Relative path within the folder (default: ".")
Returns:
Dict with folder contents or error information
"""
# Create file manager
file_manager = FileManager(memory)
# Create use case
use_case = ListFolderUseCase(file_manager)
# Execute use case
response = use_case.execute(folder_type, path)
# Return as dict
return response.to_dict()