]> Raphaël G. Git Repositories - youtubedl/blob - devscripts/gh-pages/update-copyright.py
Merge changes from buster branch for the NMU while I was away.
[youtubedl] / devscripts / gh-pages / update-copyright.py
1 #!/usr/bin/env python
2 # coding: utf-8
3
4 from __future__ import with_statement, unicode_literals
5
6 import datetime
7 import glob
8 import io # For Python 2 compatibility
9 import os
10 import re
11
12 year = str(datetime.datetime.now().year)
13 for fn in glob.glob('*.html*'):
14 with io.open(fn, encoding='utf-8') as f:
15 content = f.read()
16 newc = re.sub(r'(?P<copyright>Copyright © 2011-)(?P<year>[0-9]{4})', 'Copyright © 2011-' + year, content)
17 if content != newc:
18 tmpFn = fn + '.part'
19 with io.open(tmpFn, 'wt', encoding='utf-8') as outf:
20 outf.write(newc)
21 os.rename(tmpFn, fn)