Port blendfile parsing code from BAM to BAT? #54127

Closed
opened 2018-02-22 11:15:43 +01:00 by Sybren A. Stüvel · 3 comments

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.

The Blendfile parsing code in BAM's [blendfile.py](https://developer.blender.org/diffusion/BAM/browse/master/bam/blend/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()](https://developer.blender.org/diffusion/BAM/browse/master/bam/blend/blendfile.py;7afb1fe606b9c9e9e735653ab61859ee8a62dc22$850), 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.
Sybren A. Stüvel self-assigned this 2018-02-22 11:15:43 +01:00
Author
Member

Added subscribers: @dr.sybren, @fsiddi

Added subscribers: @dr.sybren, @fsiddi
Author
Member

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Author
Member

The blendfile parsing, and writing string properties, is all ported from BAM as of commit 127f357e49acc4c144d9c49c10f875ac91fc942e.

The blendfile parsing, and writing string properties, is all ported from BAM as of commit 127f357e49acc4c144d9c49c10f875ac91fc942e.
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#54127
No description provided.