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