You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
552 B

  1. import io
  2. import sys
  3. import re
  4. README_FILE = 'README.md'
  5. helptext = sys.stdin.read()
  6. with io.open(README_FILE, encoding='utf-8') as f:
  7. oldreadme = f.read()
  8. header = oldreadme[:oldreadme.index('# OPTIONS')]
  9. footer = oldreadme[oldreadme.index('# CONFIGURATION'):]
  10. options = helptext[helptext.index(' General Options:')+19:]
  11. options = re.sub(r'^ (\w.+)$', r'## \1', options, flags=re.M)
  12. options = '# OPTIONS\n' + options + '\n'
  13. with io.open(README_FILE, 'w', encoding='utf-8') as f:
  14. f.write(header)
  15. f.write(options)
  16. f.write(footer)