X-Git-Url: http://git.bitcoin.ninja/index.cgi?p=youtube-dl;a=blobdiff_plain;f=devscripts%2Fmake_contributing.py;h=226d1a5d6644953982db6346a00a21ec45f9b089;hp=99451c5688223cde18bbe5f7bd45fd60a2ff9345;hb=d84b21b427d080a031ca1f9c75beb1dc8024b900;hpb=e56190b378367291abe4677f2357fcfc213b1a6a diff --git a/devscripts/make_contributing.py b/devscripts/make_contributing.py index 99451c568..226d1a5d6 100755 --- a/devscripts/make_contributing.py +++ b/devscripts/make_contributing.py @@ -1,31 +1,33 @@ #!/usr/bin/env python from __future__ import unicode_literals -import argparse import io +import optparse import re def main(): - parser = argparse.ArgumentParser() - parser.add_argument( - 'INFILE', help='README.md file name to read from') - parser.add_argument( - 'OUTFILE', help='CONTRIBUTING.md file name to write to') - args = parser.parse_args() - - with io.open(args.INFILE, encoding='utf-8') as inf: + parser = optparse.OptionParser(usage='%prog INFILE OUTFILE') + options, args = parser.parse_args() + if len(args) != 2: + parser.error('Expected an input and an output filename') + + infile, outfile = args + + with io.open(infile, encoding='utf-8') as inf: readme = inf.read() bug_text = re.search( r'(?s)#\s*BUGS\s*[^\n]*\s*(.*?)#\s*COPYRIGHT', readme).group(1) dev_text = re.search( - r'(?s)(#\s*DEVELOPER INSTRUCTIONS.*?)#\s*BUGS', readme).group(1) + r'(?s)(#\s*DEVELOPER INSTRUCTIONS.*?)#\s*EMBEDDING YOUTUBE-DL', + readme).group(1) out = bug_text + dev_text - with io.open(args.OUTFILE, 'w', encoding='utf-8') as outf: + with io.open(outfile, 'w', encoding='utf-8') as outf: outf.write(out) + if __name__ == '__main__': main()