Learn preferences from a file. Args: path: File path (used to determine file type) content: File content to analyze Returns: Dictionary of detected preferences
(self, path: str, content: str)
| 303 | warning(f"Failed to save preferences: {e}") |
| 304 | |
| 305 | def learn_from_file(self, path: str, content: str) -> Dict[str, str]: |
| 306 | """ |
| 307 | Learn preferences from a file. |
| 308 | |
| 309 | Args: |
| 310 | path: File path (used to determine file type) |
| 311 | content: File content to analyze |
| 312 | |
| 313 | Returns: |
| 314 | Dictionary of detected preferences |
| 315 | """ |
| 316 | if not path.endswith(".py"): |
| 317 | return {} |
| 318 | |
| 319 | detected = PreferenceDetector.detect_all_preferences(content) |
| 320 | |
| 321 | # Update preferences with detected values |
| 322 | for key, value in detected.items(): |
| 323 | if value: |
| 324 | self._update_preference(key, value, confidence=0.3) |
| 325 | |
| 326 | return detected |
| 327 | |
| 328 | def learn_from_files(self, files: List[tuple]) -> Dict[str, List[str]]: |
| 329 | """ |