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.

32 lines
822 B

  1. #!/usr/bin/env python
  2. from __future__ import unicode_literals
  3. import argparse
  4. import io
  5. import re
  6. def main():
  7. parser = argparse.ArgumentParser()
  8. parser.add_argument(
  9. 'INFILE', help='README.md file name to read from')
  10. parser.add_argument(
  11. 'OUTFILE', help='CONTRIBUTING.md file name to write to')
  12. args = parser.parse_args()
  13. with io.open(args.INFILE, encoding='utf-8') as inf:
  14. readme = inf.read()
  15. bug_text = re.search(
  16. r'(?s)#\s*BUGS\s*[^\n]*\s*(.*?)#\s*COPYRIGHT', readme).group(1)
  17. dev_text = re.search(
  18. r'(?s)(#\s*DEVELOPER INSTRUCTIONS.*?)#\s*EMBEDDING YOUTUBE-DL',
  19. readme).group(1)
  20. out = bug_text + dev_text
  21. with io.open(args.OUTFILE, 'w', encoding='utf-8') as outf:
  22. outf.write(out)
  23. if __name__ == '__main__':
  24. main()