24 Commits

Author SHA1 Message Date
Sybren A. Stüvel
8a06bf5903 Add optional support for ZStandard compression
BAT now can take advantage of the `zstandard` module to handle Blender
3.0+ compressed blend files.

If the module is not installed, the blend files cannot be opened but
GZip-compressed and uncompressed files can still be handled.
2021-10-05 18:24:44 +02:00
Sybren A. Stüvel
087ff25c76 Add 'strict pointer mode' to BlendFile
Add a 'strict pointer mode' to the `BlendFile` class, which is enabled
by default. This allows users of the `BlendFile` class to decide whether
a bad pointer (i.e. one that points to a non-existing datablock) returns
`None` or raises a `SegmentationFault` exception.
2021-07-22 10:28:48 +02:00
Sybren A. Stüvel
803c38dac1 Cleanup: reformat with Black 2021-07-22 10:14:43 +02:00
Sybren A. Stüvel
b48978f067 Moved from Pipenv to Poetry
All the Blender Institute Python webprojects are moving to Poetry; it works
better than Pipenv in various regards.
2019-06-07 12:49:59 +02:00
Sybren A. Stüvel
c331b99dc6 Fixed leaking file descriptors in unit tests
These weren't any issue in Linux, but Windows doesn't like it when you
try to delete a still-opened file.
2018-12-20 14:04:23 +01:00
Sybren A. Stüvel
0e9de7753c Allow Packer to be used as context manager + test for rewriting img seqs 2018-03-14 12:50:27 +01:00
Sybren A. Stüvel
824ca4bcb7 Rewrite blend files in temporary directory, before copying
This allows us to later support uploading to a non-local filesystem, such
as Amazon S3 cloud storage, after path rewriting is complete.
2018-03-09 12:33:15 +01:00
Sybren A. Stüvel
384f1d5107 Compare float with assertAlmostEqual 2018-03-09 11:20:38 +01:00
Sybren A. Stüvel
7167d51730 Added BlendFileBlock.id_name property
Evaluated only once, so safe to call multiple times without producing
excessive disk I/O. Returns None instead of raising KeyError when there is
no (b'id', b'name') field.
2018-03-02 11:26:02 +01:00
Sybren A. Stüvel
f46e761f09 Removed base_index parameter in favour of explicit array handling
The `base_index` parameter is confusing and only works in a limited number
of cases. Having explicit functions to deal with those cases is preferred.
2018-03-01 12:50:22 +01:00
Sybren A. Stüvel
59c0b6df4c Allow block.get() to return the dna.Field
This is needed by the upcoming dependency tracer.
2018-02-26 18:15:14 +01:00
Sybren A. Stüvel
a56e985cdc Unify behaviour of block[path] and block.get(path) 2018-02-26 18:14:23 +01:00
Sybren A. Stüvel
bce5f4b670 Ported get_file_offset() and renamed to abs_offset() 2018-02-23 15:53:26 +01:00
Sybren A. Stüvel
db14cc5074 Test segfault 2018-02-23 14:46:47 +01:00
Sybren A. Stüvel
49d0f41b40 Test using BlendFile as context 2018-02-23 14:26:57 +01:00
Sybren A. Stüvel
9750a91571 Fixed file leak when opening corrupted file. 2018-02-23 14:26:57 +01:00
Sybren A. Stüvel
eb8281ea82 Fix leaking file object when loading non-blend file 2018-02-23 14:26:57 +01:00
Sybren A. Stüvel
67751d9a3e Fixed loading compressed files 2018-02-23 14:26:57 +01:00
Sybren A. Stüvel
b42a090f32 Support for modifying string/bytes fields. 2018-02-23 14:26:57 +01:00
Sybren A. Stüvel
934a8e210e Clarified type refinement, simplified API, custom exception for get_pointer
Type refinement is now only done with BlendFileBlock.refine_type(), and
no longer with sdna_index_refine parameters to various functions. This
simplifies the API at the expense of having to call two simple functions
instead of one more complex one.
2018-02-23 14:26:57 +01:00
Sybren A. Stüvel
63c7e4fcef Ported iteration over properties 2018-02-22 17:44:50 +01:00
Sybren A. Stüvel
7165d121bd Ported BlendFileBlock.get_recursive_iter()
Also simplified get_file_offset(), because its optional parameters are
never used anyway.
2018-02-22 16:45:16 +01:00
Sybren A. Stüvel
87300df6a3 Fixed issue reading array items and renamed some stuff 2018-02-22 16:14:10 +01:00
Sybren A. Stüvel
9c7791f762 Implemented/fixed/ported loading of blend files and getting blocks & props 2018-02-22 15:52:10 +01:00