irshadtech10/Repo_Analyzer
0
1import logging2import os3 4EXTENSION_TO_LANGUAGE_MAP = {5 ".py": "python",6 ".js": "javascript",7 ".java": "java",8 ".cpp": "cpp",9 ".c": "c",10 ".rb": "ruby",11 ".php": "php",12 ".cs": "csharp",13 ".go": "go",14 ".swift": "swift",15 ".ts": "typescript",16 ".rs": "rust",17 ".kt": "kotlin",18 ".m": "objective-c",19}20 21 22def load_environment_variables(file_path: str) -> None:23 if os.path.exists(file_path):24 with open(file_path) as f:25 for line in f:26 if line.strip():27 key, value = line.strip().split("=")28 os.environ[key] = value29 30 31def set_environment_variables() -> None:32 os.environ["TOKENIZERS_PARALLELISM"] = "false"33 34 35def configure_logging(log_file: str, level: int = logging.INFO) -> None:36 logging.basicConfig(filename=log_file, level=level)37 38 39class TempDirContext:40 def __init__(self, temp_dir: str) -> None:41 self.cwd = os.getcwd()42 self.temp_dir = temp_dir43 44 def __enter__(self):45 os.makedirs(self.temp_dir, exist_ok=True)46 os.chdir(self.temp_dir)47 48 def __exit__(self, exc_type, exc_value, traceback):49 os.chdir(self.cwd)50 