]>
Commit | Line | Data |
---|---|---|
cc52de43 | 1 | #!/usr/bin/env python3 |
54007a45 | 2 | |
3 | # Allow direct execution | |
4 | import os | |
5 | import sys | |
6 | ||
7 | sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) | |
8 | ||
9 | ||
7710bdf4 | 10 | import optparse |
7710bdf4 SO |
11 | |
12 | ||
c1714454 | 13 | def read(fname): |
14 | with open(fname, encoding='utf-8') as f: | |
15 | return f.read() | |
16 | ||
17 | ||
54007a45 | 18 | # Get the version without importing the package |
c1714454 | 19 | def read_version(fname): |
20 | exec(compile(read(fname), fname, 'exec')) | |
21 | return locals()['__version__'] | |
22 | ||
23 | ||
7710bdf4 | 24 | def main(): |
3bf1df51 | 25 | parser = optparse.OptionParser(usage='%prog INFILE OUTFILE') |
7710bdf4 | 26 | options, args = parser.parse_args() |
3bf1df51 S |
27 | if len(args) != 2: |
28 | parser.error('Expected an input and an output filename') | |
7710bdf4 | 29 | |
3bf1df51 | 30 | infile, outfile = args |
86e5f3ed | 31 | with open(outfile, 'w', encoding='utf-8') as outf: |
c1714454 | 32 | outf.write( |
33 | read(infile) % {'version': read_version('yt_dlp/version.py')}) | |
7710bdf4 | 34 | |
86e5f3ed | 35 | |
7710bdf4 SO |
36 | if __name__ == '__main__': |
37 | main() |