Write markdown file. Returns True if content changed.
(path: Path, content: str, dry_run: bool = False)
| 193 | |
| 194 | |
| 195 | def write_md(path: Path, content: str, dry_run: bool = False) -> bool: |
| 196 | """Write markdown file. Returns True if content changed.""" |
| 197 | if path.exists(): |
| 198 | old = path.read_text(encoding="utf-8") |
| 199 | if old.strip() == content.strip(): |
| 200 | return False |
| 201 | if dry_run: |
| 202 | return True |
| 203 | path.parent.mkdir(parents=True, exist_ok=True) |
| 204 | path.write_text(content, encoding="utf-8") |
| 205 | return True |
| 206 | |
| 207 | |
| 208 | # --------------------------------------------------------------------------- |
no outgoing calls
no test coverage detected