File: update-copyright.py

package info (click to toggle)
solfege 3.16.4-2
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 34,472 kB
  • ctags: 5,287
  • sloc: python: 22,642; xml: 14,196; ansic: 4,682; makefile: 621; sh: 287
file content (39 lines) | stat: -rw-r--r-- 995 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/python

import os
import sys
import re

r = re.compile("(?P<left>\# Copyright \(C\) )(?P<years>(\d\d\d\d,\s)*(\d\d\d\d))(?P<right>\s+Tom Cato Amundsen)")
def do_file(filename):
    f = file(filename, 'r')
    s = f.read()
    f.close()
    m = r.search(s)
    def func(r):
        years = r.group('years')
        if '2008' not in years:
            years ="%s, 2008" % years
        return r.group('left') + years + r.group('right')
    s2 = r.sub(func, s)
    if s2 != s:
        f = file(filename, 'w')
        f.write(s2)
        f.close()

def motto(filename):
    f = file(filename, 'r')
    s = f.read()
    f.close()
    s2 = s.replace('ear trai'+'ning for GNOME', 'free ear training software')
    if s2 != s:
        f = file(filename, 'w')
        f.write(s2)
        f.close()


for root, dirs, files in os.walk("."):
    for f in files:
        if f.endswith(".py") or f == 'Makefile':
            do_file(os.path.join(root, f))
            #motto(os.path.join(root, f))