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.

21 lines
614 B

  1. #!/usr/bin/env python
  2. # coding: utf-8
  3. from __future__ import with_statement, unicode_literals
  4. import datetime
  5. import glob
  6. import io # For Python 2 compatibility
  7. import os
  8. import re
  9. year = str(datetime.datetime.now().year)
  10. for fn in glob.glob('*.html*'):
  11. with io.open(fn, encoding='utf-8') as f:
  12. content = f.read()
  13. newc = re.sub(r'(?P<copyright>Copyright © 2006-)(?P<year>[0-9]{4})', 'Copyright © 2006-' + year, content)
  14. if content != newc:
  15. tmpFn = fn + '.part'
  16. with io.open(tmpFn, 'wt', encoding='utf-8') as outf:
  17. outf.write(newc)
  18. os.rename(tmpFn, fn)