forked from libavg/libavg
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfixcopyright.py
More file actions
executable file
·32 lines (27 loc) · 896 Bytes
/
fixcopyright.py
File metadata and controls
executable file
·32 lines (27 loc) · 896 Bytes
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
#!/usr/bin/env python
import os
import re
def handleFile(path):
lines = file(path).readlines()
lineNumber = 0
found = False
for i, line in enumerate(lines):
match = re.match(r'((//)|(#))\s*Copyright \(C\) 2003-(.*) Ulrich von Zadow\s*', line)
# m = re.match(r'#include\s*["<]([\-_a-zA-Z0-9\.\\/]+)[">]\s*', l)
if match:
if path[-2:] == 'py':
lines[i] = "# Copyright (C) 2003-2014 Ulrich von Zadow\n"
else:
lines[i] = "// Copyright (C) 2003-2014 Ulrich von Zadow\n"
found = True
if found:
outFile = open(path, "w")
for line in lines:
outFile.write(line)
else:
print path
for ext in ("h", "c", "cpp", "py"):
cmd = 'find . -name "*.'+ext+'"'
files = os.popen(cmd).readlines()
for f in files:
handleFile(f.strip())