Initial commit: CodeMap v0.1.0 - CLI tool for code analysis and diagram generation
Some checks failed
CI / test (push) Has been cancelled
CI / build (push) Has been cancelled

This commit is contained in:
2026-01-30 12:19:01 +00:00
parent cfade8cca2
commit ed721c8491

39
codemap/parsers/base.py Normal file
View File

@@ -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]