(toml: str, new_version: str)
| 68 | |
| 69 | |
| 70 | def replace_poetry_version(toml: str, new_version: str) -> tuple[str, bool]: |
| 71 | pattern = re.compile( |
| 72 | r'(\n\[tool\.poetry\][\s\S]*?\n)(version\s*=\s*\")([^\"]+)(\"\s*)(\n)', |
| 73 | re.MULTILINE, |
| 74 | ) |
| 75 | def _repl(m: re.Match) -> str: |
| 76 | return f"{m.group(1)}{m.group(2)}{new_version}{m.group(4)}{m.group(5)}" |
| 77 | new_toml, n = pattern.subn(_repl, toml, count=1) |
| 78 | return new_toml, n > 0 |
| 79 | |
| 80 | |
| 81 | def replace_workspace_package_version(toml: str, new_version: str) -> tuple[str, bool]: |