45 lines
1.3 KiB
Python
45 lines
1.3 KiB
Python
"""Category-based folder routing for output files.
|
|
|
|
Routes notes to the appropriate NoteGraph folder based on detected category:
|
|
- meeting → notes/meetings/
|
|
- project → notes/projects/
|
|
- decision → notes/decisions/
|
|
- default → notes/inbox/
|
|
"""
|
|
|
|
import logging
|
|
from pathlib import Path
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
# Category to folder mapping
|
|
CATEGORY_FOLDERS: dict[str, str] = {
|
|
"meeting": "meetings",
|
|
"project": "projects",
|
|
"decision": "decisions",
|
|
}
|
|
|
|
|
|
def route_to_folder(
|
|
category: str, notes_dir: Path, override: Path | None = None
|
|
) -> Path:
|
|
"""Determine the output folder for a note based on its category.
|
|
|
|
Args:
|
|
category: The detected category (meeting, project, decision, inbox).
|
|
notes_dir: Root notes directory (e.g., ./notes).
|
|
override: Optional explicit output directory override (--output-dir).
|
|
|
|
Returns:
|
|
Path to the target folder (created if it doesn't exist).
|
|
"""
|
|
if override is not None:
|
|
target = Path(override)
|
|
else:
|
|
folder_name = CATEGORY_FOLDERS.get(category, "inbox")
|
|
target = Path(notes_dir) / folder_name
|
|
|
|
target.mkdir(parents=True, exist_ok=True)
|
|
logger.debug("Routing category '%s' to folder: %s", category, target)
|
|
return target
|