]> jfr.im git - yt-dlp.git/blame - devscripts/make_readme.py
Preparing for release
[yt-dlp.git] / devscripts / make_readme.py
CommitLineData
dcddc10a
PH
1from __future__ import unicode_literals
2
1e91866f 3import io
4bb028f4
FV
4import sys
5import re
6
682407f2 7README_FILE = 'README.md'
4bb028f4
FV
8helptext = sys.stdin.read()
9
49f2bf76
PH
10if isinstance(helptext, bytes):
11 helptext = helptext.decode('utf-8')
12
1e91866f 13with io.open(README_FILE, encoding='utf-8') as f:
682407f2 14 oldreadme = f.read()
4bb028f4 15
c76eb41b 16header = oldreadme[:oldreadme.index('## General Options:')]
17footer = oldreadme[oldreadme.index('# CONFIGURATION'):]
4bb028f4 18
c76eb41b 19options = helptext[helptext.index(' General Options:'):]
d19bb9c0 20options = re.sub(r'(?m)^ (\w.+)$', r'## \1', options)
c76eb41b 21options = options + '\n'
4bb028f4 22
1e91866f 23with io.open(README_FILE, 'w', encoding='utf-8') as f:
682407f2 24 f.write(header)
25 f.write(options)
c76eb41b 26 f.write(footer)