(path, write, counts, skipped)
| 147 | |
| 148 | |
| 149 | def process_file(path, write, counts, skipped): |
| 150 | with open(path, "r", encoding="utf-8") as fh: |
| 151 | original = fh.read() |
| 152 | fm, body, _ = blog_text.split_front_matter(original) |
| 153 | if post_author(fm).lower() in SKIP_AUTHORS: |
| 154 | skipped.append(os.path.basename(path)) |
| 155 | return False |
| 156 | cut = len(blog_text.author_body(body)) |
| 157 | author_part, rest = body[:cut], body[cut:] |
| 158 | new_author = convert_body(author_part, counts) |
| 159 | if new_author == author_part: |
| 160 | return False |
| 161 | new_full = fm + new_author + rest |
| 162 | assert new_full.startswith(fm), f"front matter changed in {path}" |
| 163 | if write: |
| 164 | with open(path, "w", encoding="utf-8") as fh: |
| 165 | fh.write(new_full) |
| 166 | return True |
| 167 | |
| 168 | |
| 169 | def expand(paths): |
no test coverage detected