aboutsummaryrefslogtreecommitdiff
path: root/devscripts/bash-completion.py
diff options
context:
space:
mode:
Diffstat (limited to 'devscripts/bash-completion.py')
-rwxr-xr-xdevscripts/bash-completion.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/devscripts/bash-completion.py b/devscripts/bash-completion.py
index 3d1391334..7db396a77 100755
--- a/devscripts/bash-completion.py
+++ b/devscripts/bash-completion.py
@@ -5,8 +5,12 @@ 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.compat import compat_open as open
+
+from utils import read_file
BASH_COMPLETION_FILE = "youtube-dl.bash-completion"
BASH_COMPLETION_TEMPLATE = "devscripts/bash-completion.in"
@@ -18,9 +22,8 @@ def build_completion(opt_parser):
for option in group.option_list:
# for every long flag
opts_flag.append(option.get_opt_string())
- with open(BASH_COMPLETION_TEMPLATE) as f:
- template = f.read()
- with open(BASH_COMPLETION_FILE, "w") as f:
+ template = read_file(BASH_COMPLETION_TEMPLATE)
+ with open(BASH_COMPLETION_FILE, "w", encoding='utf-8') as f:
# just using the special char
filled_template = template.replace("{{flags}}", " ".join(opts_flag))
f.write(filled_template)