| 16 | self._prefix = prefix or [] |
| 17 | |
| 18 | def update(self, files): |
| 19 | for file in files: |
| 20 | with open(file, encoding="utf-8-sig") as f: |
| 21 | lines = f.readlines() |
| 22 | |
| 23 | index = -1 |
| 24 | for i, line in enumerate(lines): |
| 25 | if line.startswith(self._comment_characters) or self.valid_copyright_notice_line(line, index, file): |
| 26 | index += 1 |
| 27 | else: |
| 28 | break |
| 29 | |
| 30 | if index == -1: |
| 31 | self.write_update_notice(file, lines) |
| 32 | else: |
| 33 | current = "".join(lines[: index + 1]) |
| 34 | if current != self.copyright_notice(file): |
| 35 | self.write_update_notice(file, lines[index + 1 :]) |
| 36 | |
| 37 | def valid_copyright_notice_line(self, line, index, file): |
| 38 | return index + 1 < len(self.copyright_notice_lines(file)) and line.startswith( |