]>
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 | 15 | |
c76eb41b | 16 | header = oldreadme[:oldreadme.index('## General Options:')] |
17 | footer = oldreadme[oldreadme.index('# CONFIGURATION'):] | |
4bb028f4 | 18 | |
c76eb41b | 19 | options = helptext[helptext.index(' General Options:'):] |
d19bb9c0 | 20 | options = re.sub(r'(?m)^ (\w.+)$', r'## \1', options) |
c76eb41b | 21 | options = options + '\n' |
4bb028f4 | 22 | |
1e91866f | 23 | with io.open(README_FILE, 'w', encoding='utf-8') as f: |
682407f2 | 24 | f.write(header) |
25 | f.write(options) | |
c76eb41b | 26 | f.write(footer) |