Get file path through manual input with validation
(self)
| 295 | return None |
| 296 | |
| 297 | def _get_manual_file_path(self) -> Optional[str]: |
| 298 | """Get file path through manual input with validation""" |
| 299 | self.print_separator("─", 79, Colors.YELLOW) |
| 300 | print(f"{Colors.BOLD}{Colors.YELLOW}📁 Manual File Path Input{Colors.ENDC}") |
| 301 | print( |
| 302 | f"{Colors.CYAN}Please enter the full path to your research paper file:{Colors.ENDC}" |
| 303 | ) |
| 304 | print( |
| 305 | f"{Colors.CYAN}Supported formats: PDF, DOCX, PPTX, HTML, TXT, MD{Colors.ENDC}" |
| 306 | ) |
| 307 | self.print_separator("─", 79, Colors.YELLOW) |
| 308 | |
| 309 | while True: |
| 310 | print(f"\n{Colors.BOLD}{Colors.OKCYAN}📂 File path: {Colors.ENDC}", end="") |
| 311 | file_path = input().strip() |
| 312 | |
| 313 | if not file_path: |
| 314 | self.print_status( |
| 315 | "Empty path entered. Please try again or press Ctrl+C to cancel.", |
| 316 | "warning", |
| 317 | ) |
| 318 | continue |
| 319 | |
| 320 | file_path = os.path.expanduser(file_path) |
| 321 | file_path = os.path.abspath(file_path) |
| 322 | |
| 323 | if not os.path.exists(file_path): |
| 324 | self.print_status(f"File not found: {file_path}", "error") |
| 325 | retry = ( |
| 326 | input(f"{Colors.YELLOW}Try again? (y/n): {Colors.ENDC}") |
| 327 | .strip() |
| 328 | .lower() |
| 329 | ) |
| 330 | if retry != "y": |
| 331 | return None |
| 332 | continue |
| 333 | |
| 334 | if not os.path.isfile(file_path): |
| 335 | self.print_status(f"Path is not a file: {file_path}", "error") |
| 336 | continue |
| 337 | |
| 338 | supported_extensions = { |
| 339 | ".pdf", |
| 340 | ".docx", |
| 341 | ".doc", |
| 342 | ".pptx", |
| 343 | ".ppt", |
| 344 | ".html", |
| 345 | ".htm", |
| 346 | ".txt", |
| 347 | ".md", |
| 348 | } |
| 349 | file_ext = os.path.splitext(file_path)[1].lower() |
| 350 | |
| 351 | if file_ext not in supported_extensions: |
| 352 | self.print_status(f"Unsupported file format: {file_ext}", "warning") |
| 353 | proceed = ( |
| 354 | input(f"{Colors.YELLOW}Process anyway? (y/n): {Colors.ENDC}") |
no test coverage detected