Guido van Rossum | fc05882 | 1996-11-27 19:41:55 +0000 | [diff] [blame] | 1 | #! /usr/bin/env python |
| 2 | |
| 3 | OLD_NOTICE = """ |
| 4 | Permission to use, copy, modify, and distribute this software and its |
| 5 | documentation for any purpose and without fee is hereby granted, |
| 6 | provided that the above copyright notice appear in all copies and that |
| 7 | both that copyright notice and this permission notice appear in |
| 8 | supporting documentation, and that the names of Stichting Mathematisch |
| 9 | Centrum or CWI not be used in advertising or publicity pertaining to |
| 10 | distribution of the software without specific, written prior permission. |
| 11 | |
| 12 | STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO |
| 13 | THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND |
| 14 | FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE |
| 15 | FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 16 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 17 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT |
| 18 | OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 19 | """ |
| 20 | |
| 21 | NEW_NOTICE = """ |
Guido van Rossum | fd71b9e | 2000-06-30 23:50:40 +0000 | [diff] [blame] | 22 | Copyright (c) 2000, BeOpen.com. |
| 23 | Copyright (c) 1995-2000, Corporation for National Research Initiatives. |
| 24 | Copyright (c) 1990-1995, Stichting Mathematisch Centrum. |
| 25 | All rights reserved. |
Guido van Rossum | fc05882 | 1996-11-27 19:41:55 +0000 | [diff] [blame] | 26 | |
Guido van Rossum | fd71b9e | 2000-06-30 23:50:40 +0000 | [diff] [blame] | 27 | See the file "Misc/COPYRIGHT" for information on usage and |
| 28 | redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
Guido van Rossum | fc05882 | 1996-11-27 19:41:55 +0000 | [diff] [blame] | 29 | """ |
| 30 | |
| 31 | # " <-- Help Emacs |
| 32 | |
| 33 | import os, sys, string |
| 34 | |
| 35 | def main(): |
| 36 | args = sys.argv[1:] |
| 37 | if not args: |
Guido van Rossum | ed5b3d8 | 1998-03-24 05:30:29 +0000 | [diff] [blame] | 38 | print "No arguments." |
Guido van Rossum | fc05882 | 1996-11-27 19:41:55 +0000 | [diff] [blame] | 39 | for arg in args: |
Guido van Rossum | ed5b3d8 | 1998-03-24 05:30:29 +0000 | [diff] [blame] | 40 | process(arg) |
Guido van Rossum | fc05882 | 1996-11-27 19:41:55 +0000 | [diff] [blame] | 41 | |
| 42 | def process(arg): |
| 43 | f = open(arg) |
| 44 | data = f.read() |
| 45 | f.close() |
| 46 | i = string.find(data, OLD_NOTICE) |
| 47 | if i < 0: |
Guido van Rossum | ed5b3d8 | 1998-03-24 05:30:29 +0000 | [diff] [blame] | 48 | ## print "No old notice in", arg |
| 49 | return |
Guido van Rossum | fc05882 | 1996-11-27 19:41:55 +0000 | [diff] [blame] | 50 | data = data[:i] + NEW_NOTICE + data[i+len(OLD_NOTICE):] |
| 51 | new = arg + ".new" |
| 52 | backup = arg + ".bak" |
| 53 | print "Replacing notice in", arg, "...", |
| 54 | sys.stdout.flush() |
| 55 | f = open(new, "w") |
| 56 | f.write(data) |
| 57 | f.close() |
| 58 | os.rename(arg, backup) |
| 59 | os.rename(new, arg) |
| 60 | print "done" |
| 61 | |
| 62 | if __name__ == '__main__': |
| 63 | main() |