diff options
author | Tim Peters <tim.peters@gmail.com> | 2004-07-18 06:16:08 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2004-07-18 06:16:08 (GMT) |
commit | 182b5aca27d376b08a2904bed42b751496f932f3 (patch) | |
tree | df13115820dbc879c0fe2eae488c9f8c0215a7da /Lib/plat-mac/Carbon/MediaDescr.py | |
parent | e6ddc8b20b493fef2e7cffb2e1351fe1d238857e (diff) | |
download | cpython-182b5aca27d376b08a2904bed42b751496f932f3.zip cpython-182b5aca27d376b08a2904bed42b751496f932f3.tar.gz cpython-182b5aca27d376b08a2904bed42b751496f932f3.tar.bz2 |
Whitespace normalization, via reindent.py.
Diffstat (limited to 'Lib/plat-mac/Carbon/MediaDescr.py')
-rw-r--r-- | Lib/plat-mac/Carbon/MediaDescr.py | 82 |
1 files changed, 41 insertions, 41 deletions
diff --git a/Lib/plat-mac/Carbon/MediaDescr.py b/Lib/plat-mac/Carbon/MediaDescr.py index acacfb1..254634b 100644 --- a/Lib/plat-mac/Carbon/MediaDescr.py +++ b/Lib/plat-mac/Carbon/MediaDescr.py @@ -4,58 +4,58 @@ import struct Error = 'MediaDescr.Error' class _MediaDescriptionCodec: - def __init__(self, trunc, size, names, fmt): - self.trunc = trunc - self.size = size - self.names = names - self.fmt = fmt + def __init__(self, trunc, size, names, fmt): + self.trunc = trunc + self.size = size + self.names = names + self.fmt = fmt - def decode(self, data): - if self.trunc: - data = data[:self.size] - values = struct.unpack(self.fmt, data) - if len(values) != len(self.names): - raise Error, ('Format length does not match number of names', descr) - rv = {} - for i in range(len(values)): - name = self.names[i] - value = values[i] - if type(name) == type(()): - name, cod, dec = name - value = dec(value) - rv[name] = value - return rv + def decode(self, data): + if self.trunc: + data = data[:self.size] + values = struct.unpack(self.fmt, data) + if len(values) != len(self.names): + raise Error, ('Format length does not match number of names', descr) + rv = {} + for i in range(len(values)): + name = self.names[i] + value = values[i] + if type(name) == type(()): + name, cod, dec = name + value = dec(value) + rv[name] = value + return rv - def encode(dict): - list = [self.fmt] - for name in self.names: - if type(name) == type(()): - name, cod, dec = name - else: - cod = dec = None - value = dict[name] - if cod: - value = cod(value) - list.append(value) - rv = struct.pack(*list) - return rv + def encode(dict): + list = [self.fmt] + for name in self.names: + if type(name) == type(()): + name, cod, dec = name + else: + cod = dec = None + value = dict[name] + if cod: + value = cod(value) + list.append(value) + rv = struct.pack(*list) + return rv # Helper functions def _tofixed(float): - hi = int(float) - lo = int(float*0x10000) & 0xffff - return (hi<<16)|lo + hi = int(float) + lo = int(float*0x10000) & 0xffff + return (hi<<16)|lo def _fromfixed(fixed): - hi = (fixed >> 16) & 0xffff - lo = (fixed & 0xffff) - return hi + (lo / float(0x10000)) + hi = (fixed >> 16) & 0xffff + lo = (fixed & 0xffff) + return hi + (lo / float(0x10000)) def _tostr31(str): - return chr(len(str)) + str + '\0'*(31-len(str)) + return chr(len(str)) + str + '\0'*(31-len(str)) def _fromstr31(str31): - return str31[1:1+ord(str31[0])] + return str31[1:1+ord(str31[0])] SampleDescription = _MediaDescriptionCodec( 1, # May be longer, truncate |