Initial upload: Auto README Generator CLI v0.1.0
Some checks failed
CI / build (push) Has been cancelled
CI / release (push) Has been cancelled
CI / test (push) Has been cancelled

This commit is contained in:
2026-02-05 08:40:08 +00:00
parent be36f32896
commit 4c0bef0d70

View File

@@ -0,0 +1,39 @@
"""Dependency parser factory for routing to correct parser."""
from pathlib import Path
from typing import Optional
from . import DependencyParser
from .python_parser import PythonDependencyParser
from .javascript_parser import JavaScriptDependencyParser
from .go_parser import GoDependencyParser
from .rust_parser import RustDependencyParser
class DependencyParserFactory:
"""Factory for creating appropriate dependency parsers."""
PARSERS = [
PythonDependencyParser(),
JavaScriptDependencyParser(),
GoDependencyParser(),
RustDependencyParser(),
]
@classmethod
def get_parser(cls, path: Path) -> Optional[DependencyParser]:
"""Get the appropriate parser for a file."""
for parser in cls.PARSERS:
if parser.can_parse(path):
return parser
return None
@classmethod
def get_all_parsers(cls) -> list[DependencyParser]:
"""Get all available parsers."""
return cls.PARSERS.copy()
@classmethod
def can_parse(cls, path: Path) -> bool:
"""Check if any parser can handle the file."""
return cls.get_parser(path) is not None