File: copyright-update.py

package info (click to toggle)
python-libtrace 1.6%2Bgit20161027-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,124 kB
  • ctags: 1,357
  • sloc: ansic: 6,890; python: 3,228; makefile: 70; sh: 49
file content (48 lines) | stat: -rw-r--r-- 1,071 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
40
41
42
43
44
45
46
47
48
#!/usr/bin/env python

# Copyright (C) 2015 by Nevil Brownlee, U Auckland | WAND

import glob, os

def find_copyright(fn):
    #f = open(fn+".new", "r")
    f = open(fn, "r")
    print fn
    for line in f:
        if line.find("yright") >= 0:
            print "   %s" % line.strip()
            return True
    f.close()
    return False

def fix_file(fn):
    print fn
    f = open(fn, "r");  nf = open(fn+".new", "w")
    for line in f:
        if line.find("yright") >= 0:
            la = line.split("2014")
            if len(la) == 2:
                nf.write(la[0] + "2015" + la[1])
            else:
                nf.write(line)
            #print "la = %s" % la
        else:
            nf.write(line)
    nf.close();  f.close()
    #os.rename(fn+".new", fn)
    
def checkfiles(gstr):
    for fn in glob.glob(gstr):
        find_copyright(fn)
        #fix_file(fn)

checkfiles("*.py")
checkfiles("*.sh")
checkfiles("Makefile")
checkfiles("README")

checkfiles("lib/*/*.c")
checkfiles("lib/*/*.h")
checkfiles("test/*/*.py")
checkfiles("doc/examples/*.py")