(
cls,
seed: int,
body: str,
enclosing_label: Optional[str] = None,
sanitize_key: bool = False,
)
| 5537 | |
| 5538 | @classmethod |
| 5539 | def safe_construct( |
| 5540 | cls, |
| 5541 | seed: int, |
| 5542 | body: str, |
| 5543 | enclosing_label: Optional[str] = None, |
| 5544 | sanitize_key: bool = False, |
| 5545 | ) -> _anonymous_label: |
| 5546 | # need to escape chars that interfere with format |
| 5547 | # strings in any case, issue #8724 |
| 5548 | body = re.sub(r"[%\(\) \$]+", "_", body) |
| 5549 | |
| 5550 | if sanitize_key: |
| 5551 | # sanitize_key is then an extra step used by BindParameter |
| 5552 | body = body.strip("_") |
| 5553 | |
| 5554 | label = "%%(%d %s)s" % (seed, body.replace("%", "%%")) |
| 5555 | if enclosing_label: |
| 5556 | label = "%s%s" % (enclosing_label, label) |
| 5557 | |
| 5558 | return _anonymous_label(label) |
| 5559 | |
| 5560 | def __add__(self, other): |
| 5561 | if "%" in other and not isinstance(other, _anonymous_label): |
no test coverage detected