1 |
# |
# |
2 |
# Copyright (c) 2002, Benja Fallenstein |
# Copyright (c) 2002, Benja Fallenstein |
3 |
# |
# |
4 |
# You may use and distribute under the terms of either the GNU Lesser |
# You may use and distribute under the terms of either the GNU Lesser |
5 |
# General Public License, either version 2 of the license or, |
# General Public License, either version 2 of the license or, |
6 |
# at your choice, any later version. Alternatively, you may use and |
# at your choice, any later version. Alternatively, you may use and |
7 |
# distribute under the terms of the XPL. |
# distribute under the terms of the XPL. |
8 |
# |
# |
9 |
# See the LICENSE.lgpl and LICENSE.xpl files for the specific terms of |
# See the LICENSE.lgpl and LICENSE.xpl files for the specific terms of |
10 |
# the licenses. |
# the licenses. |
11 |
# |
# |
12 |
# This software is distributed in the hope that it will be useful, |
# This software is distributed in the hope that it will be useful, |
13 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the README |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the README |
15 |
# file for more details. |
# file for more details. |
16 |
# |
# |
17 |
|
|
18 |
""" |
""" |
19 |
copyrighter.py -- utility to add copyright notices to source files |
copyrighter.py -- utility to add copyright notices to source files |
22 |
one of the following lines: |
one of the following lines: |
23 |
|
|
24 |
//(c): PERSON |
//(c): PERSON |
25 |
|
// (c) PERSON |
26 |
#(c): PERSON |
#(c): PERSON |
27 |
|
|
28 |
where PERSON is any string. It then inserts a Gzz-ish copyright statement |
where PERSON is any string. It then inserts a Gzz-ish copyright statement |
71 |
for name in names: |
for name in names: |
72 |
file = os.path.join(dir, name) |
file = os.path.join(dir, name) |
73 |
if os.path.isdir(file): continue |
if os.path.isdir(file): continue |
74 |
first = open(file, 'r').read(6) |
first = open(file, 'r').read(7) |
75 |
|
|
76 |
if first.startswith('//(c):') or first.startswith('#(c):'): |
if first.startswith('//(c):') or first.startswith('#(c):') or \ |
77 |
|
first.startswith('// (c) '): |
78 |
if first.startswith('#'): |
if first.startswith('#'): |
79 |
pymode = 1; chars = 5 |
pymode = 1; chars = 5 |
80 |
else: |
else: |
81 |
pymode = 0; chars = 6 |
pymode = 0; |
82 |
|
if first.startswith('// '): |
83 |
|
chars = 7 |
84 |
|
else: |
85 |
|
chars = 6 |
86 |
|
|
87 |
lines = [] |
lines = [] |
88 |
for l in open(file, 'r').readlines(): |
for l in open(file, 'r').readlines(): |