diff options
Diffstat (limited to 'TOOLS/matroska.py')
-rwxr-xr-x | TOOLS/matroska.py | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/TOOLS/matroska.py b/TOOLS/matroska.py index 0e447bc5ea..e715c229df 100755 --- a/TOOLS/matroska.py +++ b/TOOLS/matroska.py @@ -21,8 +21,6 @@ Can also be used to directly parse Matroska files and display their contents. # License along with mpv. If not, see <http://www.gnu.org/licenses/>. # -# for compatibility with Python 2.x -from __future__ import print_function elements_ebml = ( 'EBML, 1a45dfa3, sub', ( @@ -276,7 +274,7 @@ class MatroskaElement(object): def add_subelements(self, subelements): self.subelements = subelements - self.subids = set(x[0].elid for x in subelements) + self.subids = {x[0].elid for x in subelements} elementd = {} elementlist = [] @@ -300,8 +298,8 @@ parse_elems(elements_ebml, 'EBML') parse_elems(elements_matroska, 'MATROSKA') def printf(out, *args): - out.write(u' '.join([str(x) for x in args])) - out.write(u'\n') + out.write(' '.join(str(x) for x in args)) + out.write('\n') def generate_C_header(out): printf(out, '// Generated by TOOLS/matroska.py, do not edit manually') @@ -461,13 +459,16 @@ if __name__ == "__main__": def parse_toplevel(s): parse_one(s, 0, None, 1 << 63) + if len(sys.argv) < 3: + outfile = sys.stdout + else: + outfile = open(sys.argv[2], "w") + if sys.argv[1] == '--generate-header': - generate_C_header(sys.stdout) + generate_C_header(outfile) elif sys.argv[1] == '--generate-definitions': - generate_C_definitions(sys.stdout) + generate_C_definitions(outfile) else: - if sys.version_info.major < 3: - raise Exception("Dumping requires Python 3.") s = open(sys.argv[1], "rb") while 1: start = s.tell() |