aboutsummaryrefslogtreecommitdiff
path: root/devscripts/fish-completion.py
diff options
context:
space:
mode:
authordirkf <fieldhouse@gmx.net>2023-07-25 00:22:54 +0100
committerdirkf <fieldhouse@gmx.net>2023-07-25 13:19:43 +0100
commitb87018122995acb7e6a1be3f2464605259b93611 (patch)
tree11f47d8a9d8e32e04cf5eca2fa9c82448fff49e9 /devscripts/fish-completion.py
parenta25e9f3c84a34d43f78a4e5a6f6c2e98e2a0ade3 (diff)
downloadyoutube-dl-b87018122995acb7e6a1be3f2464605259b93611.tar.xz
[build] Extend use of `devscripts/utils`
Diffstat (limited to 'devscripts/fish-completion.py')
-rwxr-xr-xdevscripts/fish-completion.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/devscripts/fish-completion.py b/devscripts/fish-completion.py
index 51d19dd33..267ba6a58 100755
--- a/devscripts/fish-completion.py
+++ b/devscripts/fish-completion.py
@@ -6,10 +6,13 @@ import os
from os.path import dirname as dirn
import sys
-sys.path.insert(0, dirn(dirn((os.path.abspath(__file__)))))
+sys.path.insert(0, dirn(dirn(os.path.abspath(__file__))))
+
import youtube_dl
from youtube_dl.utils import shell_quote
+from utils import read_file, write_file
+
FISH_COMPLETION_FILE = 'youtube-dl.fish'
FISH_COMPLETION_TEMPLATE = 'devscripts/fish-completion.in'
@@ -38,11 +41,9 @@ def build_completion(opt_parser):
complete_cmd.extend(EXTRA_ARGS.get(long_option, []))
commands.append(shell_quote(complete_cmd))
- with open(FISH_COMPLETION_TEMPLATE) as f:
- template = f.read()
+ template = read_file(FISH_COMPLETION_TEMPLATE)
filled_template = template.replace('{{commands}}', '\n'.join(commands))
- with open(FISH_COMPLETION_FILE, 'w') as f:
- f.write(filled_template)
+ write_file(filled_template)
parser = youtube_dl.parseOpts()[0]