-#!/usr/bin/env python
-from __future__ import unicode_literals
-
+#!/usr/bin/env python3
import io
import optparse
+def read(fname):
+ with open(fname, encoding='utf-8') as f:
+ return f.read()
+
+
+# Get the version from yt_dlp/version.py without importing the package
+def read_version(fname):
+ exec(compile(read(fname), fname, 'exec'))
+ return locals()['__version__']
+
+
def main():
parser = optparse.OptionParser(usage='%prog INFILE OUTFILE')
options, args = parser.parse_args()
parser.error('Expected an input and an output filename')
infile, outfile = args
+ with open(outfile, 'w', encoding='utf-8') as outf:
+ outf.write(
+ read(infile) % {'version': read_version('yt_dlp/version.py')})
- with io.open(infile, encoding='utf-8') as inf:
- issue_template_tmpl = inf.read()
-
- __version__ = None
-
- # Get the version from youtube_dl/version.py without importing the package
- exec(compile(open('youtube_dl/version.py').read(),
- 'youtube_dl/version.py', 'exec'))
-
- out = issue_template_tmpl % {'version': __version__}
-
- with io.open(outfile, 'w', encoding='utf-8') as outf:
- outf.write(out)
if __name__ == '__main__':
main()