From 2cef169d4c8872394065606821075c7acb71ef25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Chv=C3=A1tal?= Date: Mon, 13 Aug 2012 14:12:05 +0200 Subject: [PATCH] Add py2 compat. Now scripts work under both py3 and py2. --- TOOLS/file2string.py | 7 +++++-- TOOLS/matroska.py | 4 +++- TOOLS/vdpau_functions.py | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/TOOLS/file2string.py b/TOOLS/file2string.py index 002ba4a..1f8d493 100755 --- a/TOOLS/file2string.py +++ b/TOOLS/file2string.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 +#!/usr/bin/env python # Convert the contents of a file into a C string constant. # Note that the compiler will implicitly add an extra 0 byte at the end @@ -16,7 +16,10 @@ def main(infile): for c, esc in ("\nn", "\tt", r"\\", '""'): conv[ord(c)] = '\\' + esc for line in infile: - sys.stdout.write('"' + ''.join(conv[c] for c in line) + '"\n') + try: + sys.stdout.write('"' + ''.join(conv[ord(c)] for c in line) + '"\n') + except TypeError: + sys.stdout.write('"' + ''.join(conv[c] for c in line) + '"\n') with open(sys.argv[1], 'rb') as infile: sys.stdout.write("// Generated from %s\n\n" % sys.argv[1]) diff --git a/TOOLS/matroska.py b/TOOLS/matroska.py index ffa388e..5b34d7d 100755 --- a/TOOLS/matroska.py +++ b/TOOLS/matroska.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 +#!/usr/bin/env python """ Generate C definitions for parsing Matroska files. Can also be used to directly parse Matroska files and display their contents. @@ -22,6 +22,8 @@ Can also be used to directly parse Matroska files and display their contents. # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # +# Python2 compat so we don't enforce py3 usage +from __future__ import print_function elements_ebml = ( 'EBML, 1a45dfa3, sub', ( diff --git a/TOOLS/vdpau_functions.py b/TOOLS/vdpau_functions.py index 39e38a8..85e6f1d 100755 --- a/TOOLS/vdpau_functions.py +++ b/TOOLS/vdpau_functions.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 +#!/usr/bin/env python # Generate vdpau_template.c -- 1.7.8.6