From 4cf62518bf9f48e5931321b4207c1e32315f0b3a Mon Sep 17 00:00:00 2001 From: 7000pctAUTO Date: Thu, 29 Jan 2026 13:21:17 +0000 Subject: [PATCH] Add project and language analyzers --- src/contextgen/analyzers/base.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/contextgen/analyzers/base.py diff --git a/src/contextgen/analyzers/base.py b/src/contextgen/analyzers/base.py new file mode 100644 index 0000000..fce6429 --- /dev/null +++ b/src/contextgen/analyzers/base.py @@ -0,0 +1,24 @@ +"""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