addheader.py 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. header = """\
  2. /*************************************************************************/
  3. /* $filename */
  4. /*************************************************************************/
  5. /* This file is part of: */
  6. /* GODOT ENGINE */
  7. /* http://www.godotengine.org */
  8. /*************************************************************************/
  9. /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /*************************************************************************/
  30. """
  31. f = open("files", "rb")
  32. fname = f.readline()
  33. while (fname != ""):
  34. fr = open(fname.strip(), "rb")
  35. l = fr.readline()
  36. bc = False
  37. fsingle = fname.strip()
  38. if (fsingle.find("/") != -1):
  39. fsingle = fsingle[fsingle.rfind("/") + 1:]
  40. rep_fl = "$filename"
  41. rep_fi = fsingle
  42. len_fl = len(rep_fl)
  43. len_fi = len(rep_fi)
  44. if (len_fi < len_fl):
  45. for x in range(len_fl - len_fi):
  46. rep_fi += " "
  47. elif (len_fl < len_fi):
  48. for x in range(len_fi - len_fl):
  49. rep_fl += " "
  50. if (header.find(rep_fl) != -1):
  51. text = header.replace(rep_fl, rep_fi)
  52. else:
  53. text = header.replace("$filename", fsingle)
  54. while (l != ""):
  55. if ((l.find("//") != 0 and l.find("/*") != 0 and l.strip() != "") or bc):
  56. text += l
  57. bc = True
  58. l = fr.readline()
  59. fr.close()
  60. fr = open(fname.strip(), "wb")
  61. fr.write(text)
  62. fr.close()
  63. # print(text)
  64. fname = f.readline()