(orig_code: str, updated_code: str, filename: str, dry_run: bool)
| 2083 | |
| 2084 | @staticmethod |
| 2085 | def write_code(orig_code: str, updated_code: str, filename: str, dry_run: bool) -> bool: |
| 2086 | if dry_run: |
| 2087 | diff = difflib.unified_diff(orig_code.splitlines(1), updated_code.splitlines(1)) |
| 2088 | changes = "".join(diff) |
| 2089 | print("Diff:") |
| 2090 | print(changes) |
| 2091 | return len(changes) > 0 |
| 2092 | else: |
| 2093 | if updated_code != orig_code: |
| 2094 | with open(filename, "w") as w: |
| 2095 | w.write(updated_code) |
| 2096 | return True |
| 2097 | |
| 2098 | def apply( |
| 2099 | self, |
no test coverage detected