aboutsummaryrefslogtreecommitdiffstats
path: root/devscripts/make_issue_template.py
diff options
context:
space:
mode:
authorpukkandan <pukkandan.ytdlp@gmail.com>2022-08-09 01:08:47 +0530
committerpukkandan <pukkandan.ytdlp@gmail.com>2022-08-09 01:08:47 +0530
commit115add43876964956917bf596c1d0b148c5b3c26 (patch)
tree3274c61d8d9440b414394c34b1ac76a8cb300116 /devscripts/make_issue_template.py
parentc4b6c5c7c9eb0aa448d03c1540580cdd92737aa8 (diff)
downloadhypervideo-pre-115add43876964956917bf596c1d0b148c5b3c26.tar.lz
hypervideo-pre-115add43876964956917bf596c1d0b148c5b3c26.tar.xz
hypervideo-pre-115add43876964956917bf596c1d0b148c5b3c26.zip
[devscripts] Create `utils` and refactor
Diffstat (limited to 'devscripts/make_issue_template.py')
-rw-r--r--devscripts/make_issue_template.py40
1 files changed, 19 insertions, 21 deletions
diff --git a/devscripts/make_issue_template.py b/devscripts/make_issue_template.py
index 90e7e0b43..fd964c6c6 100644
--- a/devscripts/make_issue_template.py
+++ b/devscripts/make_issue_template.py
@@ -7,20 +7,14 @@ import sys
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
-import optparse
import re
-
-def read(fname):
- with open(fname, encoding='utf-8') as f:
- return f.read()
-
-
-# Get the version without importing the package
-def read_version(fname):
- exec(compile(read(fname), fname, 'exec'))
- return locals()['__version__']
-
+from devscripts.utils import (
+ get_filename_args,
+ read_file,
+ read_version,
+ write_file,
+)
VERBOSE_TMPL = '''
- type: checkboxes
@@ -58,20 +52,24 @@ VERBOSE_TMPL = '''
required: true
'''.strip()
+NO_SKIP = '''
+ - type: checkboxes
+ attributes:
+ label: DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE
+ description: Fill all fields even if you think it is irrelevant for the issue
+ options:
+ - label: I understand that I will be **blocked** if I remove or skip any mandatory\\* field
+ required: true
+'''.strip()
-def main():
- parser = optparse.OptionParser(usage='%prog INFILE OUTFILE')
- _, args = parser.parse_args()
- if len(args) != 2:
- parser.error('Expected an input and an output filename')
- fields = {'version': read_version('yt_dlp/version.py')}
+def main():
+ fields = {'version': read_version(), 'no_skip': NO_SKIP}
fields['verbose'] = VERBOSE_TMPL % fields
fields['verbose_optional'] = re.sub(r'(\n\s+validations:)?\n\s+required: true', '', fields['verbose'])
- infile, outfile = args
- with open(outfile, 'w', encoding='utf-8') as outf:
- outf.write(read(infile) % fields)
+ infile, outfile = get_filename_args(has_infile=True)
+ write_file(outfile, read_file(infile) % fields)
if __name__ == '__main__':