addheader.py 3.1 KB

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