summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2017-01-31 14:47:11 +0100
committerwm4 <wm4@nowhere>2017-01-31 14:47:11 +0100
commit55d6408526214d8ec97aab25a20396944c6d04ad (patch)
tree46aa7677d80ed1d95d00e0851b7c211c9aa825f8
parentc178920505b530f411d0bc93f9e55278af557fc7 (diff)
downloadmpv-55d6408526214d8ec97aab25a20396944c6d04ad.tar.bz2
mpv-55d6408526214d8ec97aab25a20396944c6d04ad.tar.xz
TOOLS/matroska.py: fix some minor things for dumping
TOOLS/matroska.py can be used stand-alone for dumping Matroska file contents. Fix some related issues. Elements were treated as unknown if the element hex ID contained uppercase characters. Unknown elements stopped parsing. This was intentional, but I don't really see any reason for it. Dumping with Python 2 is broken. I don't care, but everytime I hit this, I find myself trying to find out why. So make it error out explicitly.
-rwxr-xr-xTOOLS/matroska.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/TOOLS/matroska.py b/TOOLS/matroska.py
index 3f8ebd7dd6..4343a5f56b 100755
--- a/TOOLS/matroska.py
+++ b/TOOLS/matroska.py
@@ -271,6 +271,7 @@ def parse_elems(l, namespace):
for el in l:
if isinstance(el, str):
name, hexid, eltype = [x.strip() for x in el.split(',')]
+ hexid = hexid.lower()
multiple = name.endswith('*')
name = name.strip('*')
new = MatroskaElement(name, hexid, eltype, namespace)
@@ -400,10 +401,6 @@ def read_float(s, length):
def parse_one(s, depth, parent, maxlen):
elid = hexlify(read_id(s)).decode('ascii')
elem = elementd.get(elid)
- if parent is not None and elid not in parent.subids and elid not in ('ec', 'bf'):
- print('Unexpected:', elid)
- if 1:
- raise NotImplementedError
size, length = read_vint(s)
this_length = len(elid) / 2 + size + length
if elem is not None:
@@ -442,7 +439,7 @@ def parse_one(s, depth, parent, maxlen):
else:
raise NotImplementedError
else:
- print(depth, 'Unknown element:', elid, 'size:', length)
+ print(" " * depth, '[' + elid + '] Unknown element! size:', length)
read(s, length)
return this_length
@@ -455,6 +452,8 @@ if __name__ == "__main__":
elif sys.argv[1] == '--generate-definitions':
generate_C_definitions(sys.stdout)
else:
+ if sys.version_info.major < 3:
+ raise Exception("Dumping requires Python 3.")
s = open(sys.argv[1], "rb")
while 1:
start = s.tell()