Go to the documentation of this file.00001
00002
00003 import os
00004 import datetime
00005
00006 exclude_folders = ["lib", "bin", "build", "qpoases", "templates"]
00007
00008 def update_license(filename, copyright):
00009 utfstr = chr(0xef) + chr(0xbb) + chr(0xbf)
00010 fdata = file(filename, "r+").read()
00011
00012 isUTF = False
00013 if (fdata.startswith(utfstr)):
00014 isUTF = True
00015 fdata = fdata[3:]
00016
00017 if fdata.startswith( "/*" ):
00018
00019
00020
00021 fdata = fdata[fdata.find( "*/" ) + 2:]
00022
00023
00024 ndata = copyright[:-1] + fdata
00025
00026 print "Updating: " + filename
00027 if (isUTF):
00028 file(filename, "w").write(utfstr + ndata)
00029 else:
00030 file(filename, "w").write(ndata)
00031
00032 def recursive_traversal(dir, copyright):
00033 global exclude_folders
00034 fns = os.listdir(dir)
00035 for fn in fns:
00036 fullfn = os.path.join(dir, fn)
00037 if (os.path.isdir(fullfn)):
00038 if (os.path.basename( fullfn ) in exclude_folders):
00039 continue
00040 recursive_traversal(fullfn, copyright)
00041 else:
00042 if (fullfn.endswith(".cpp") or fullfn.endswith(".hpp") or fullfn.endswith(".ipp")):
00043 update_license(fullfn, copyright)
00044
00045
00046 copyright = file("license_header_cpp.txt", "r+").read() % datetime.datetime.today().year
00047
00048 folders = ["../include",
00049 "../src",
00050 "../external_packages/include",
00051 "../external_packages/src",
00052 "../examples"]
00053
00054 for f in folders:
00055 recursive_traversal(f, copyright)