Generic detector for preferred library from a map.
(cls, content: str, lib_map: Dict, category: str)
| 186 | |
| 187 | @classmethod |
| 188 | def detect_preferred_library(cls, content: str, lib_map: Dict, category: str) -> Optional[str]: |
| 189 | """Generic detector for preferred library from a map.""" |
| 190 | scores = defaultdict(int) |
| 191 | for lib, patterns in lib_map.items(): |
| 192 | for p in patterns: |
| 193 | if re.search(p, content, re.MULTILINE): |
| 194 | scores[lib] += 1 |
| 195 | return max(scores, key=scores.get) if scores else None |
| 196 | |
| 197 | @classmethod |
| 198 | def detect_log_style(cls, content: str) -> Optional[str]: |
no test coverage detected