Initial upload: TermDiagram v0.1.0
This commit is contained in:
25
src/termdiagram/parser/language_detector.py
Normal file
25
src/termdiagram/parser/language_detector.py
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
from typing import List
|
||||||
|
|
||||||
|
|
||||||
|
class LanguageDetector:
|
||||||
|
SUPPORTED_EXTENSIONS = {
|
||||||
|
"py": "python",
|
||||||
|
"js": "javascript",
|
||||||
|
"ts": "typescript",
|
||||||
|
"rs": "rust",
|
||||||
|
"go": "go",
|
||||||
|
"java": "java",
|
||||||
|
"cpp": "cpp",
|
||||||
|
"c": "c",
|
||||||
|
"rb": "ruby",
|
||||||
|
"php": "php",
|
||||||
|
}
|
||||||
|
|
||||||
|
def is_supported(self, extension: str) -> bool:
|
||||||
|
return extension in self.SUPPORTED_EXTENSIONS
|
||||||
|
|
||||||
|
def get_language(self, extension: str) -> Optional[str]:
|
||||||
|
return self.SUPPORTED_EXTENSIONS.get(extension)
|
||||||
|
|
||||||
|
def get_supported_extensions(self) -> List[str]:
|
||||||
|
return list(self.SUPPORTED_EXTENSIONS.keys())
|
||||||
Reference in New Issue
Block a user