The Blendfile parsing code in BAM's blendfile.py works mostly fine, and should be ported to BAT.
- Break into a few separate files.
- Convert module-like classes to actual modules.
- Instead of passing the BlendFileHeader object around all the time, which is then used to find the endianness index, which is then used to find the correct struct to parse data, for each field that needs to be read, take a more object-oriented approach and construct an object once that then just points to the correct struct.
- Use pathlib.Path for concrete paths of files to access.
- In general, use a more Pythonic approach.
One thing to note is that there currently seems to be a bug in write_string(), which truncates the string to the field length before encoding to UTF-8, rather than truncating the encoded bytes. Furthermore, it should avoid truncating in the middle of a character and producing invalid UTF-8.