1# This file is part of Eigen, a lightweight C++ template library 2# for linear algebra. 3# 4# Copyright (C) 2012 Keir Mierle <mierle@gmail.com> 5# 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/. 9# 10# Author: mierle@gmail.com (Keir Mierle) 11# 12# Make the long-awaited conversion to MPL. 13 14lgpl3_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. 19// 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. 24// 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. 29// 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''' 34 35mpl2_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""" 40 41import os 42import sys 43 44exclusions = set(['relicense.py']) 45 46def update(text): 47 if text.find(lgpl3_header) == -1: 48 return text, False 49 return text.replace(lgpl3_header, mpl2_header), True 50 51rootdir = sys.argv[1] 52for 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() 61 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 70