MCPcopy
hub / github.com/NVIDIA/Isaac-GR00T / replace_once

Function replace_once

tests/test_support/readme.py:103–106  ·  view source on GitHub ↗

Replace ``old`` with ``new`` in ``text``, asserting exactly one occurrence.

(text: str, old: str, new: str)

Source from the content-addressed store, hash-verified

101
102
103def replace_once(text: str, old: str, new: str) -> str:
104 """Replace ``old`` with ``new`` in ``text``, asserting exactly one occurrence."""
105 assert text.count(old) == 1, f"Expected exactly one occurrence of {old!r}"
106 return text.replace(old, new)
107
108
109def run_bash_blocks(

Calls

no outgoing calls