Merged in f5soh/librepilot/update_credits (pull request #529)
[librepilot.git] / ground / gcs / src / libs / eigen / scripts / relicense.py
blob8a5265f1f171ab8afc7cc7892a773099f7723d84
1 # This file is part of Eigen, a lightweight C++ template library
2 # for linear algebra.
4 # Copyright (C) 2012 Keir Mierle <mierle@gmail.com>
6 # This Source Code Form is subject to the terms of the Mozilla
7 # Public License v. 2.0. If a copy of the MPL was not distributed
8 # with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 # Author: mierle@gmail.com (Keir Mierle)
12 # Make the long-awaited conversion to MPL.
14 lgpl3_header = '''
15 // Eigen is free software; you can redistribute it and/or
16 // modify it under the terms of the GNU Lesser General Public
17 // License as published by the Free Software Foundation; either
18 // version 3 of the License, or (at your option) any later version.
20 // Alternatively, you can redistribute it and/or
21 // modify it under the terms of the GNU General Public License as
22 // published by the Free Software Foundation; either version 2 of
23 // the License, or (at your option) any later version.
25 // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
26 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
27 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
28 // GNU General Public License for more details.
30 // You should have received a copy of the GNU Lesser General Public
31 // License and a copy of the GNU General Public License along with
32 // Eigen. If not, see <http://www.gnu.org/licenses/>.
33 '''
35 mpl2_header = """
36 // This Source Code Form is subject to the terms of the Mozilla
37 // Public License v. 2.0. If a copy of the MPL was not distributed
38 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
39 """
41 import os
42 import sys
44 exclusions = set(['relicense.py'])
46 def update(text):
47 if text.find(lgpl3_header) == -1:
48 return text, False
49 return text.replace(lgpl3_header, mpl2_header), True
51 rootdir = sys.argv[1]
52 for root, sub_folders, files in os.walk(rootdir):
53 for basename in files:
54 if basename in exclusions:
55 print 'SKIPPED', filename
56 continue
57 filename = os.path.join(root, basename)
58 fo = file(filename)
59 text = fo.read()
60 fo.close()
62 text, updated = update(text)
63 if updated:
64 fo = file(filename, "w")
65 fo.write(text)
66 fo.close()
67 print 'UPDATED', filename
68 else:
69 print ' ', filename