You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
2.3 KiB

  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. lgpl3_header = '''
  14. // Eigen is free software; you can redistribute it and/or
  15. // modify it under the terms of the GNU Lesser General Public
  16. // License as published by the Free Software Foundation; either
  17. // version 3 of the License, or (at your option) any later version.
  18. //
  19. // Alternatively, you can redistribute it and/or
  20. // modify it under the terms of the GNU General Public License as
  21. // published by the Free Software Foundation; either version 2 of
  22. // the License, or (at your option) any later version.
  23. //
  24. // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
  25. // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  26. // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
  27. // GNU General Public License for more details.
  28. //
  29. // You should have received a copy of the GNU Lesser General Public
  30. // License and a copy of the GNU General Public License along with
  31. // Eigen. If not, see <http://www.gnu.org/licenses/>.
  32. '''
  33. mpl2_header = """
  34. // This Source Code Form is subject to the terms of the Mozilla
  35. // Public License v. 2.0. If a copy of the MPL was not distributed
  36. // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
  37. """
  38. import os
  39. import sys
  40. exclusions = set(['relicense.py'])
  41. def update(text):
  42. if text.find(lgpl3_header) == -1:
  43. return text, False
  44. return text.replace(lgpl3_header, mpl2_header), True
  45. rootdir = sys.argv[1]
  46. for root, sub_folders, files in os.walk(rootdir):
  47. for basename in files:
  48. if basename in exclusions:
  49. print 'SKIPPED', filename
  50. continue
  51. filename = os.path.join(root, basename)
  52. fo = file(filename)
  53. text = fo.read()
  54. fo.close()
  55. text, updated = update(text)
  56. if updated:
  57. fo = file(filename, "w")
  58. fo.write(text)
  59. fo.close()
  60. print 'UPDATED', filename
  61. else:
  62. print ' ', filename