(self, file)
| 312 | _file = None # Set here since __del__ checks it |
| 313 | |
| 314 | def initfp(self, file): |
| 315 | self._version = 0 |
| 316 | self._convert = None |
| 317 | self._markers = [] |
| 318 | self._soundpos = 0 |
| 319 | self._file = file |
| 320 | chunk = Chunk(file) |
| 321 | if chunk.getname() != b'FORM': |
| 322 | raise Error('file does not start with FORM id') |
| 323 | formdata = chunk.read(4) |
| 324 | if formdata == b'AIFF': |
| 325 | self._aifc = 0 |
| 326 | elif formdata == b'AIFC': |
| 327 | self._aifc = 1 |
| 328 | else: |
| 329 | raise Error('not an AIFF or AIFF-C file') |
| 330 | self._comm_chunk_read = 0 |
| 331 | self._ssnd_chunk = None |
| 332 | while 1: |
| 333 | self._ssnd_seek_needed = 1 |
| 334 | try: |
| 335 | chunk = Chunk(self._file) |
| 336 | except EOFError: |
| 337 | break |
| 338 | chunkname = chunk.getname() |
| 339 | if chunkname == b'COMM': |
| 340 | self._read_comm_chunk(chunk) |
| 341 | self._comm_chunk_read = 1 |
| 342 | elif chunkname == b'SSND': |
| 343 | self._ssnd_chunk = chunk |
| 344 | dummy = chunk.read(8) |
| 345 | self._ssnd_seek_needed = 0 |
| 346 | elif chunkname == b'FVER': |
| 347 | self._version = _read_ulong(chunk) |
| 348 | elif chunkname == b'MARK': |
| 349 | self._readmark(chunk) |
| 350 | chunk.skip() |
| 351 | if not self._comm_chunk_read or not self._ssnd_chunk: |
| 352 | raise Error('COMM chunk and/or SSND chunk missing') |
| 353 | |
| 354 | def __init__(self, f): |
| 355 | if isinstance(f, str): |
no test coverage detected