update_license_header_cpp.py
Go to the documentation of this file.
1 #!/usr/bin/python
2 
3 import os
4 import datetime
5 
6 exclude_folders = ["lib", "bin", "build", "qpoases", "templates"]
7 
8 def update_license(filename, copyright):
9  utfstr = chr(0xef) + chr(0xbb) + chr(0xbf)
10  fdata = file(filename, "r+").read()
11 
12  isUTF = False
13  if (fdata.startswith(utfstr)):
14  isUTF = True
15  fdata = fdata[3:]
16 
17  if fdata.startswith( "/*" ):
18  # File starts with a header
19 
20  # Find end of the comment and trim the file
21  fdata = fdata[fdata.find( "*/" ) + 2:]
22 
23  # Now write data to the file
24  ndata = copyright[:-1] + fdata
25 
26  print "Updating: " + filename
27  if (isUTF):
28  file(filename, "w").write(utfstr + ndata)
29  else:
30  file(filename, "w").write(ndata)
31 
32 def recursive_traversal(dir, copyright):
33  global exclude_folders
34  fns = os.listdir(dir)
35  for fn in fns:
36  fullfn = os.path.join(dir, fn)
37  if (os.path.isdir(fullfn)):
38  if (os.path.basename( fullfn ) in exclude_folders):
39  continue
40  recursive_traversal(fullfn, copyright)
41  else:
42  if (fullfn.endswith(".cpp") or fullfn.endswith(".hpp") or fullfn.endswith(".ipp")):
43  update_license(fullfn, copyright)
44 
45 # Read copyright data
46 copyright = file("license_header_cpp.txt", "r+").read() % datetime.datetime.today().year
47 # Update the licensing information
48 folders = ["../include",
49  "../src",
50  "../external_packages/include",
51  "../external_packages/src",
52  "../examples"]
53 
54 for f in folders:
55  recursive_traversal(f, copyright)
def recursive_traversal(dir, copyright)
def update_license(filename, copyright)


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Mon Jun 10 2019 12:35:15