add-mpl-license.py 662 B

1234567891011121314151617181920212223242526272829303132
  1. #!/usr/bin/env python
  2. import sys
  3. license_lines = """/*
  4. * This Source Code Form is subject to the terms of the Mozilla Public
  5. * License, v. 2.0. If a copy of the MPL was not distributed with this
  6. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  7. */
  8. """
  9. def main ():
  10. if len(sys.argv) < 2:
  11. return
  12. for filepath in sys.argv[1:]:
  13. process_file(filepath)
  14. def process_file (filepath):
  15. file_in = open(filepath, "rb")
  16. content = file_in.read()
  17. file_in.close()
  18. file_out = open(filepath, "wb")
  19. file_out.write(license_lines)
  20. file_out.write(content)
  21. file_out.close()
  22. if __name__ == '__main__':
  23. main()