Write content to path if it does not already exist with the same content.
(path: str, content: str)
| 121 | |
| 122 | |
| 123 | def _maybe_write(path: str, content: str) -> None: |
| 124 | """Write content to path if it does not already exist with the same content.""" |
| 125 | p = Path(path) |
| 126 | if p.exists(): |
| 127 | with p.open() as f: |
| 128 | existing_content = f.read() |
| 129 | if existing_content == content: |
| 130 | return |
| 131 | with p.open("w") as f: |
| 132 | f.write(content) |
| 133 | |
| 134 | |
| 135 | @functools.lru_cache |
no outgoing calls
no test coverage detected