(fname, content, hunk)
| 119 | |
| 120 | |
| 121 | def do_replace(fname, content, hunk): |
| 122 | fname = Path(fname) |
| 123 | |
| 124 | before_text, after_text = hunk_to_before_after(hunk) |
| 125 | |
| 126 | # does it want to make a new file? |
| 127 | if not fname.exists() and not before_text.strip(): |
| 128 | fname.touch() |
| 129 | content = "" |
| 130 | |
| 131 | if content is None: |
| 132 | return |
| 133 | |
| 134 | # TODO: handle inserting into new file |
| 135 | if not before_text.strip(): |
| 136 | # append to existing file, or start a new file |
| 137 | new_content = content + after_text |
| 138 | return new_content |
| 139 | |
| 140 | new_content = None |
| 141 | |
| 142 | new_content = apply_hunk(content, hunk) |
| 143 | if new_content: |
| 144 | return new_content |
| 145 | |
| 146 | |
| 147 | def collapse_repeats(s): |
no test coverage detected