From 22c8c82b4d524ece4fd11b00bae6f77b142eea70 Mon Sep 17 00:00:00 2001 From: Patrick von Reth Date: Wed, 25 Jan 2012 16:54:45 +0100 Subject: [PATCH] added a scipt to update the license header --- update_license.py | 57 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 update_license.py diff --git a/update_license.py b/update_license.py new file mode 100644 index 0000000..291d7b7 --- /dev/null +++ b/update_license.py @@ -0,0 +1,57 @@ +import os +import sys +import re + +rn = re.compile("\r\n$",re.MULTILINE) +n = re.compile("(? * + * * + * This program is free software; you can redistribute it and/or modify it under * + * the terms of the GNU General Public License as published by the Free Software * + * Foundation; either version 2 of the License, or (at your option) any later * + * version. * + * * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY * + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * + * PARTICULAR PURPOSE. See the GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License along with * + * this program. If not, see . * + ****************************************************************************************/""" + +def myWalk(root): + for root,folders,files in os.walk(root): + for folder in folders: + if not (folder == ".git" or folder == ".svn"): + myWalk(os.path.join(root,folder)) + for fileName in files: + fileName = os.path.join(root,fileName) + if os.path.isfile(fileName) and (fileName.endswith(".h") or fileName.endswith(".cpp")): + f = open(fileName,"rb+") + tmp = f.read() + f.close() + tmp = str(tmp,"UTF-8") + + lineEnding = "\r\n" + if re.search(rn,tmp) == None: + lineEnding = "\n" + + tmp = re.sub(oldLicense,newLicense,tmp) + tmp = re.sub(n,lineEnding,tmp) + #print(re.findall(oldLicense,tmp)) + f = open(fileName,"wb+") + f.write(tmp.encode("UTF-8")) + f.close() + #sys.exit(0) + + + +myWalk(sys.argv[1]) +sys.exit(0) + + +