(self, file, lines)
| 56 | return [f"{self._comment_characters} {line}".rstrip() + "\n" for line in self.NOTICE.split("\n")] |
| 57 | |
| 58 | def write_update_notice(self, file, lines): |
| 59 | # Build new content |
| 60 | new_content = self.copyright_notice(file) + "\n" |
| 61 | if lines and lines[0] != "\n": |
| 62 | new_content += "\n" |
| 63 | new_content += "".join(line.rstrip() + "\n" for line in lines) |
| 64 | |
| 65 | # Only write if different |
| 66 | with open(file, encoding="utf-8-sig") as f: |
| 67 | old_content = f.read() |
| 68 | if new_content == old_content: |
| 69 | return |
| 70 | |
| 71 | print(f"Adding notice to {file}") |
| 72 | with open(file, "w") as f: |
| 73 | f.write(new_content) |
| 74 | |
| 75 | |
| 76 | ROOT = Path(os.path.realpath(__file__)).parent.parent |
no test coverage detected