replace.py 827 B

12345678910111213141516171819202122232425262728
  1. # SPDX-License-Identifier: GPL-3.0+
  2. import os, fnmatch
  3. def find_files(directory, pattern):
  4. for root, dirs, files in os.walk(directory):
  5. for basename in files:
  6. if fnmatch.fnmatch(basename, pattern):
  7. filename = os.path.join(root, basename)
  8. yield filename
  9. cp_old = "Copyright (C) 2013 HAL@ShurabaP <https://github.com/haruneko>"
  10. cp_new = "Copyright (C) 2010-2013 HAL@ShurabaP <https://github.com/haruneko>"
  11. def replace_copyright(filename,old,new):
  12. txt = open(filename).read()
  13. txt2 = txt.replace(old,new)
  14. open(filename+".bak","w").write(txt)
  15. open(filename,"w").write(txt2)
  16. for filename in find_files('.', '*.cpp'):
  17. replace_copyright(filename,cp_old,cp_new)
  18. for filename in find_files('.', '*.h'):
  19. replace_copyright(filename,cp_old,cp_new)