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