diff options
Diffstat (limited to 'fixcopyright.py')
-rwxr-xr-x | fixcopyright.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/fixcopyright.py b/fixcopyright.py new file mode 100755 index 0000000..2c0ba1d --- /dev/null +++ b/fixcopyright.py @@ -0,0 +1,32 @@ +#!/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()) + |