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 = """ |
| 22 | Permission to use, copy, modify, and distribute this software and its |
| 23 | documentation for any purpose and without fee is hereby granted, |
| 24 | provided that the above copyright notice appear in all copies and that |
| 25 | both that copyright notice and this permission notice appear in |
| 26 | supporting documentation, and that the names of Stichting Mathematisch |
| 27 | Centrum or CWI or Corporation for National Research Initiatives or |
| 28 | CNRI not be used in advertising or publicity pertaining to |
| 29 | distribution of the software without specific, written prior |
| 30 | permission. |
| 31 | |
| 32 | While CWI is the initial source for this software, a modified version |
| 33 | is made available by the Corporation for National Research Initiatives |
| 34 | (CNRI) at the Internet address ftp://ftp.python.org. |
| 35 | |
| 36 | STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH |
| 37 | REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF |
| 38 | MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH |
| 39 | CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL |
| 40 | DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 41 | PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 42 | TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 43 | PERFORMANCE OF THIS SOFTWARE. |
| 44 | """ |
| 45 | |
| 46 | # " <-- Help Emacs |
| 47 | |
| 48 | import os, sys, string |
| 49 | |
| 50 | def main(): |
| 51 | args = sys.argv[1:] |
| 52 | if not args: |
Guido van Rossum | ed5b3d8 | 1998-03-24 05:30:29 +0000 | [diff] [blame] | 53 | print "No arguments." |
Guido van Rossum | fc05882 | 1996-11-27 19:41:55 +0000 | [diff] [blame] | 54 | for arg in args: |
Guido van Rossum | ed5b3d8 | 1998-03-24 05:30:29 +0000 | [diff] [blame] | 55 | process(arg) |
Guido van Rossum | fc05882 | 1996-11-27 19:41:55 +0000 | [diff] [blame] | 56 | |
| 57 | def process(arg): |
| 58 | f = open(arg) |
| 59 | data = f.read() |
| 60 | f.close() |
| 61 | i = string.find(data, OLD_NOTICE) |
| 62 | if i < 0: |
Guido van Rossum | ed5b3d8 | 1998-03-24 05:30:29 +0000 | [diff] [blame] | 63 | ## print "No old notice in", arg |
| 64 | return |
Guido van Rossum | fc05882 | 1996-11-27 19:41:55 +0000 | [diff] [blame] | 65 | data = data[:i] + NEW_NOTICE + data[i+len(OLD_NOTICE):] |
| 66 | new = arg + ".new" |
| 67 | backup = arg + ".bak" |
| 68 | print "Replacing notice in", arg, "...", |
| 69 | sys.stdout.flush() |
| 70 | f = open(new, "w") |
| 71 | f.write(data) |
| 72 | f.close() |
| 73 | os.rename(arg, backup) |
| 74 | os.rename(new, arg) |
| 75 | print "done" |
| 76 | |
| 77 | if __name__ == '__main__': |
| 78 | main() |