From a9d2f7e8945abfb792b76ba551f568d3580c30a6 Mon Sep 17 00:00:00 2001 From: gcmalloc Date: Fri, 7 Dec 2012 21:59:59 +0100 Subject: [PATCH] making the script compatible with python3 --- Makefile | 8 +++----- devscripts/bash_completion.py | 8 ++++++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index e152b00ac..119c1eeaa 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -all: youtube-dl README.md README.txt youtube-dl.1 youtube-dl.bash-completion +all: youtube-dl README.md README.txt youtube-dl.1 youtube-dl.bash-completion clean: rm -rf youtube-dl youtube-dl.exe youtube-dl.1 youtube-dl.bash-completion README.txt MANIFEST build/ dist/ @@ -38,10 +38,8 @@ README.txt: README.md youtube-dl.1: README.md pandoc -s -f markdown -t man README.md -o youtube-dl.1 -youtube-dl.bash-completion: README.md youtube-dl.bash-completion.in - @options=`egrep -o '(--[a-z-]+) ' README.md | sort -u | xargs echo` && \ - content=`sed "s/opts=\"[^\"]*\"/opts=\"$${options}\"/g" youtube-dl.bash-completion.in` && \ - echo "$${content}" > youtube-dl.bash-completion +youtube-dl.bash-completion: README.md devscripts/bash_completion.template + python devscripts/bash_completion.py youtube-dl.tar.gz: all tar -czf youtube-dl.tar.gz -s "|^./|./youtube-dl/|" \ diff --git a/devscripts/bash_completion.py b/devscripts/bash_completion.py index 1cbfa8bec..704034f22 100644 --- a/devscripts/bash_completion.py +++ b/devscripts/bash_completion.py @@ -1,4 +1,9 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python +import os +from os.path import dirname as dirn +import sys + +sys.path.append(dirn(dirn((os.path.abspath(__file__))))) import youtube_dl BASH_COMPLETION_FILE = "youtube-dl.bash_completion" @@ -14,7 +19,6 @@ def build_completion(opt_parser): template = f.read() with open(BASH_COMPLETION_FILE, "w") as f: #just using the special char - print opts_flag filled_template = template.replace("{{flags}}", " ".join(opts_flag)) f.write(filled_template)