6 with open(fname
, encoding
='utf-8') as f
:
10 def write_file(fname
, content
):
11 with open(fname
, 'w', encoding
='utf-8') as f
:
12 return f
.write(content
)
15 # Get the version without importing the package
16 def read_version(fname
='yt_dlp/version.py'):
17 exec(compile(read_file(fname
), fname
, 'exec'))
18 return locals()['__version__']
21 def get_filename_args(has_infile
=False, default_outfile
=None):
22 parser
= argparse
.ArgumentParser()
24 parser
.add_argument('infile', help='Input file')
25 kwargs
= {'nargs': '?', 'default': default_outfile}
if default_outfile
else {}
26 parser
.add_argument('outfile', **kwargs
, help='Output file')
28 opts
= parser
.parse_args()
30 return opts
.infile
, opts
.outfile
34 def compose_functions(*functions
):
35 return lambda x
: functools
.reduce(lambda y
, f
: f(y
), functions
, x
)