make_contributing.py 790 B

12345678910111213141516171819202122232425262728293031323334
  1. #!/usr/bin/env python
  2. from __future__ import unicode_literals
  3. import io
  4. import optparse
  5. import re
  6. def main():
  7. parser = optparse.OptionParser(usage='%prog INFILE OUTFILE')
  8. options, args = parser.parse_args()
  9. if len(args) != 2:
  10. parser.error('Expected an input and an output filename')
  11. infile, outfile = args
  12. with io.open(infile, encoding='utf-8') as inf:
  13. readme = inf.read()
  14. bug_text = re.search(
  15. r'(?s)#\s*BUGS\s*[^\n]*\s*(.*?)#\s*COPYRIGHT', readme).group(1)
  16. dev_text = re.search(
  17. r'(?s)(#\s*DEVELOPER INSTRUCTIONS.*?)#\s*EMBEDDING YOUTUBE-DL',
  18. readme).group(1)
  19. out = bug_text + dev_text
  20. with io.open(outfile, 'w', encoding='utf-8') as outf:
  21. outf.write(out)
  22. if __name__ == '__main__':
  23. main()