(obs_text: str, som_id: int, target_caption: str)
| 181 | |
| 182 | |
| 183 | def _replace_target_caption(obs_text: str, som_id: int, target_caption: str) -> str: |
| 184 | # Match the first description content in "description: <caption (may contain ",")>, url" |
| 185 | prefix = obs_text[: obs_text.index(f"\n[{som_id}]")] |
| 186 | obs_text = obs_text[obs_text.index(f"\n[{som_id}]") :] |
| 187 | modified_obs_text = re.sub(r"description: (.*?), url", f"description: {target_caption}, url", obs_text, count=1) |
| 188 | return prefix + modified_obs_text |
| 189 | |
| 190 | |
| 191 | def replace_target_caption(obs_text: str, som_id: Union[int, List[int]], target_caption: str) -> str: |
no outgoing calls
no test coverage detected