This module contains the IFFReader class which can be used as a base class for reading Maya IFF files. The class parses the structure of the file and invokes a callback method for every chunk found in the file. The actual decoding of the chunk data has to be done in a derived class.
The IFFReader class reads Maya IFF files and calls appropriate methods which have to be implemented in a derived class. A Maya IFF file is composed of chunks that contain the actual data. There can be data chunks that contain the actual data and group chunks that contain the data chunks.
Creates an instance of the reader. iffType may be a four-character string defining the type of IFF files the object is supposed to handle (it is the type of the first group chunk). If None is passed, any IFF file will be processed. For example, when set to "Maya", the read() method will raise an error if the input file is not a Maya binary file.
The file name (if it could be obtained). This may be used for generating warning or error messages.
Read the content of a file. file is either a file like object that can be used to read the content of the file or the name of a file.
Aborts reading the current file. This method can be called in handler methods to abort reading the file.
Callback that is called whenever a new group tag begins. chunk is a GroupChunk object containing information about the group chunk.
Callback that is called whenever a group goes out of scope. chunk is a GroupChunk object containing information about the group chunk (it is the same instance that was passed to onBeginGroup()).
A Chunk object is passed to the callback methods of the MBReader class. It contains information about the current chunk and it can be used to read the actual chunk data. A Chunk object has the following attributes and methods:
This is a string containing four characters that represent the chunk name.
The size in bytes of the data part of the chunk.
The absolute position of the data part within the input file.
The depth of the chunk (i.e. how deep it is nested). The root has a depth of 0.
The GroupChunk object of the parent chunk. In the case of the root group chunk this attribute is None.
Return a string containing the full path to this chunk. The result is a concatenation of all chunk names that lead to this chunk.
Read the specified number of bytes from the chunk. If bytes is -1 the entire chunk data is read. The return value is a string containing the binary data.
The GroupChunk class is derived from the Chunk class, so it has the same attributes and methods. In addition it defines one more attribute: