]> Raphaƫl G. Git Repositories - youtubedl/blob - devscripts/make_readme.py
Merge tag 'upstream/2017.02.07'
[youtubedl] / devscripts / make_readme.py
1 from __future__ import unicode_literals
2
3 import io
4 import sys
5 import re
6
7 README_FILE = 'README.md'
8 helptext = sys.stdin.read()
9
10 if isinstance(helptext, bytes):
11 helptext = helptext.decode('utf-8')
12
13 with io.open(README_FILE, encoding='utf-8') as f:
14 oldreadme = f.read()
15
16 header = oldreadme[:oldreadme.index('# OPTIONS')]
17 footer = oldreadme[oldreadme.index('# CONFIGURATION'):]
18
19 options = helptext[helptext.index(' General Options:') + 19:]
20 options = re.sub(r'(?m)^ (\w.+)$', r'## \1', options)
21 options = '# OPTIONS\n' + options + '\n'
22
23 with io.open(README_FILE, 'w', encoding='utf-8') as f:
24 f.write(header)
25 f.write(options)
26 f.write(footer)