Guido van Rossum | fc05882 | 1996-11-27 19:41:55 +0000 | [diff] [blame] | 1 | #! /usr/bin/env python |
| 2 | |
Guido van Rossum | 8586991 | 2000-09-01 23:29:29 +0000 | [diff] [blame] | 3 | OLD_NOTICE = """/*********************************************************** |
Guido van Rossum | fd71b9e | 2000-06-30 23:50:40 +0000 | [diff] [blame] | 4 | Copyright (c) 2000, BeOpen.com. |
| 5 | Copyright (c) 1995-2000, Corporation for National Research Initiatives. |
| 6 | Copyright (c) 1990-1995, Stichting Mathematisch Centrum. |
| 7 | All rights reserved. |
Guido van Rossum | fc05882 | 1996-11-27 19:41:55 +0000 | [diff] [blame] | 8 | |
Guido van Rossum | fd71b9e | 2000-06-30 23:50:40 +0000 | [diff] [blame] | 9 | See the file "Misc/COPYRIGHT" for information on usage and |
| 10 | redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
Guido van Rossum | 8586991 | 2000-09-01 23:29:29 +0000 | [diff] [blame] | 11 | ******************************************************************/ |
Guido van Rossum | fc05882 | 1996-11-27 19:41:55 +0000 | [diff] [blame] | 12 | """ |
| 13 | |
Guido van Rossum | 8586991 | 2000-09-01 23:29:29 +0000 | [diff] [blame] | 14 | NEW_NOTICE = "" |
| 15 | |
Guido van Rossum | fc05882 | 1996-11-27 19:41:55 +0000 | [diff] [blame] | 16 | # " <-- Help Emacs |
| 17 | |
| 18 | import os, sys, string |
| 19 | |
| 20 | def main(): |
| 21 | args = sys.argv[1:] |
| 22 | if not args: |
Guido van Rossum | ed5b3d8 | 1998-03-24 05:30:29 +0000 | [diff] [blame] | 23 | print "No arguments." |
Guido van Rossum | fc05882 | 1996-11-27 19:41:55 +0000 | [diff] [blame] | 24 | for arg in args: |
Guido van Rossum | ed5b3d8 | 1998-03-24 05:30:29 +0000 | [diff] [blame] | 25 | process(arg) |
Guido van Rossum | fc05882 | 1996-11-27 19:41:55 +0000 | [diff] [blame] | 26 | |
| 27 | def process(arg): |
| 28 | f = open(arg) |
| 29 | data = f.read() |
| 30 | f.close() |
| 31 | i = string.find(data, OLD_NOTICE) |
| 32 | if i < 0: |
Guido van Rossum | ed5b3d8 | 1998-03-24 05:30:29 +0000 | [diff] [blame] | 33 | ## print "No old notice in", arg |
| 34 | return |
Guido van Rossum | fc05882 | 1996-11-27 19:41:55 +0000 | [diff] [blame] | 35 | data = data[:i] + NEW_NOTICE + data[i+len(OLD_NOTICE):] |
| 36 | new = arg + ".new" |
| 37 | backup = arg + ".bak" |
| 38 | print "Replacing notice in", arg, "...", |
| 39 | sys.stdout.flush() |
| 40 | f = open(new, "w") |
| 41 | f.write(data) |
| 42 | f.close() |
| 43 | os.rename(arg, backup) |
| 44 | os.rename(new, arg) |
| 45 | print "done" |
| 46 | |
| 47 | if __name__ == '__main__': |
| 48 | main() |