[ie] Resolve `language` to ISO639-2 for ISM formats (#11359)
[yt-dlp3.git] / devscripts / set-variant.py
blob24ce4552d5e0835dd2eae733b0cb63eb5465dc86
1 #!/usr/bin/env python3
3 # Allow direct execution
4 import os
5 import sys
7 sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
10 import argparse
11 import functools
12 import re
14 from devscripts.utils import compose_functions, read_file, write_file
16 VERSION_FILE = 'yt_dlp/version.py'
19 def parse_options():
20 parser = argparse.ArgumentParser(description='Set the build variant of the package')
21 parser.add_argument('variant', help='Name of the variant')
22 parser.add_argument('-M', '--update-message', default=None, help='Message to show in -U')
23 return parser.parse_args()
26 def property_setter(name, value):
27 return functools.partial(re.sub, rf'(?m)^{name}\s*=\s*.+$', f'{name} = {value!r}')
30 opts = parse_options()
31 transform = compose_functions(
32 property_setter('VARIANT', opts.variant),
33 property_setter('UPDATE_HINT', opts.update_message),
36 write_file(VERSION_FILE, transform(read_file(VERSION_FILE)))