(doc: Any, dummy0: Any)
| 526 | |
| 527 | |
| 528 | def _parse_legacy_regex(doc: Any, dummy0: Any) -> Any: |
| 529 | pattern = doc["$regex"] |
| 530 | # Check if this is the $regex query operator. |
| 531 | if not isinstance(pattern, (str, bytes)): |
| 532 | return doc |
| 533 | flags = 0 |
| 534 | # PyMongo always adds $options but some other tools may not. |
| 535 | for opt in doc.get("$options", ""): |
| 536 | flags |= _RE_OPT_TABLE.get(opt, 0) |
| 537 | return Regex(pattern, flags) |
| 538 | |
| 539 | |
| 540 | def _parse_legacy_uuid(doc: Any, json_options: JSONOptions) -> Union[Binary, uuid.UUID]: |