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