(self, file, lines)
| 68 | return [f"{self._comment_characters} {line}".rstrip() + "\n" for line in self.NOTICE.split("\n")] |
| 69 | |
| 70 | def write_update_notice(self, file, lines): |
| 71 | # Build new content |
| 72 | new_content = self.copyright_notice(file) + "\n" |
| 73 | if lines and lines[0] != "\n": |
| 74 | new_content += "\n" |
| 75 | new_content += "".join(line.rstrip() + "\n" for line in lines) |
| 76 | |
| 77 | # Only write if different |
| 78 | with open(file, encoding="utf-8-sig") as f: |
| 79 | old_content = f.read() |
| 80 | if new_content == old_content: |
| 81 | return |
| 82 | |
| 83 | print(f"Adding notice to {file}") |
| 84 | with open(file, "w") as f: |
| 85 | f.write(new_content) |
| 86 | |
| 87 | |
| 88 | ROOT = Path(os.path.realpath(__file__)).parent.parent |
no test coverage detected