make_contributing.py 720 B

123456789101112131415161718192021222324252627282930313233
  1. #!/usr/bin/env python
  2. from __future__ import unicode_literals
  3. import optparse
  4. import re
  5. from utils import read_file, write_file
  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. readme = read_file(infile)
  13. bug_text = re.search(
  14. r'(?s)#\s*BUGS\s*[^\n]*\s*(.*?)#\s*COPYRIGHT', readme).group(1)
  15. dev_text = re.search(
  16. r'(?s)(#\s*DEVELOPER INSTRUCTIONS.*?)#\s*EMBEDDING YOUTUBE-DL',
  17. readme).group(1)
  18. out = bug_text + dev_text
  19. write_file(outfile, out)
  20. if __name__ == '__main__':
  21. main()