(self, message: Dict[str, Any], pattern: str)
| 157 | return str(hash(str(message))) |
| 158 | |
| 159 | def _extract_code(self, message: Dict[str, Any], pattern: str) -> Optional[str]: |
| 160 | subject = str(message.get("subject") or "").strip() |
| 161 | if subject: |
| 162 | match = re.search(pattern, subject) |
| 163 | if match: |
| 164 | return match.group(1) |
| 165 | fallback = subject.split(" ")[-1].strip() |
| 166 | if re.fullmatch(r"\d{4,8}", fallback): |
| 167 | return fallback |
| 168 | |
| 169 | blob = "\n".join( |
| 170 | str(message.get(key) or "") |
| 171 | for key in ("subject", "text", "body", "html", "from") |
| 172 | ) |
| 173 | match = re.search(pattern, blob) |
| 174 | if match: |
| 175 | return match.group(1) |
| 176 | return None |
| 177 | |
| 178 | def create_email(self, config: Dict[str, Any] = None) -> Dict[str, Any]: |
| 179 | try: |
no test coverage detected