From ed721c8491ed4c82919a7763143a7d33ebee93ab Mon Sep 17 00:00:00 2001 From: 7000pctAUTO Date: Fri, 30 Jan 2026 12:19:01 +0000 Subject: [PATCH] Initial commit: CodeMap v0.1.0 - CLI tool for code analysis and diagram generation --- codemap/parsers/base.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 codemap/parsers/base.py diff --git a/codemap/parsers/base.py b/codemap/parsers/base.py new file mode 100644 index 0000000..37c4fbe --- /dev/null +++ b/codemap/parsers/base.py @@ -0,0 +1,39 @@ +from abc import ABC, abstractmethod +from dataclasses import dataclass +from pathlib import Path +from typing import List, Set + + +@dataclass +class Dependency: + module_name: str + file_path: Path + line_number: int + alias: str = None + + +@dataclass +class ParsedFile: + file_path: Path + module_name: str + dependencies: List[Dependency] + file_type: str + + +class BaseParser(ABC): + supported_extensions: List[str] = [] + + @abstractmethod + def parse(self, file_path: Path) -> ParsedFile: + pass + + @abstractmethod + def extract_module_name(self, file_path: Path) -> str: + pass + + def can_parse(self, file_path: Path) -> bool: + return file_path.suffix in self.supported_extensions + + def _clean_import_name(self, import_str: str) -> str: + parts = import_str.split(".") + return parts[0]