(
cls, seed: int | str, body: str, sanitize_key: bool = False
)
| 5973 | |
| 5974 | @classmethod |
| 5975 | def safe_construct_with_key( |
| 5976 | cls, seed: int | str, body: str, sanitize_key: bool = False |
| 5977 | ) -> typing_Tuple[_anonymous_label, str]: |
| 5978 | # need to escape chars that interfere with format |
| 5979 | # strings in any case, issue #8724 |
| 5980 | body = _anonymous_label_escape.sub("_", body) |
| 5981 | |
| 5982 | if sanitize_key: |
| 5983 | # sanitize_key is then an extra step used by BindParameter |
| 5984 | body = body.strip("_") |
| 5985 | |
| 5986 | key = f"{seed} {body.replace('%', '%%')}" |
| 5987 | label = _anonymous_label(f"%({key})s") |
| 5988 | return label, key |
| 5989 | |
| 5990 | @classmethod |
| 5991 | def safe_construct( |
no test coverage detected