Files
project-context-generator/src/contextgen/analyzers/base.py
7000pctAUTO 4cf62518bf
Some checks failed
CI / test (push) Has been cancelled
CI / build (push) Has been cancelled
Add project and language analyzers
2026-01-29 13:21:17 +00:00

25 lines
706 B
Python

"""Base analyzer class for all project analyzers."""
from abc import ABC, abstractmethod
from pathlib import Path
from typing import Any
class BaseAnalyzer(ABC):
"""Base class for all project analyzers."""
def __init__(self, project_path: Path):
self.project_path = project_path
@abstractmethod
def analyze(self) -> dict[str, Any]:
"""Analyze the project and return results."""
pass
def _safe_read_file(self, path: Path, encoding: str = "utf-8") -> str | None:
"""Safely read a file, returning None on error."""
try:
return path.read_text(encoding=encoding)
except (IOError, UnicodeDecodeError):
return None