feat: avoid dumping read only properties
This commit is contained in:
@ -86,7 +86,8 @@ def np_dump_collection(collection: bpy.types.CollectionProperty, attributes: lis
|
||||
properties = collection[0].bl_rna.properties
|
||||
|
||||
if attributes is None:
|
||||
attributes = [p.identifier for p in properties if p.type in NP_COMPATIBLE_TYPES and not p.is_readonly]
|
||||
attributes = [
|
||||
p.identifier for p in properties if p.type in NP_COMPATIBLE_TYPES and not p.is_readonly]
|
||||
|
||||
for attr in attributes:
|
||||
attr_type = properties[attr].type
|
||||
@ -97,7 +98,8 @@ def np_dump_collection(collection: bpy.types.CollectionProperty, attributes: lis
|
||||
elif attr_type == 'ENUM':
|
||||
dumped_collection[attr] = np_dump_collection_enum(collection, attr)
|
||||
else:
|
||||
logging.error(f"{attr} of type {attr_type} not supported. Only {PRIMITIVE_TYPES} and ENUM supported. Skipping it.")
|
||||
logging.error(
|
||||
f"{attr} of type {attr_type} not supported. Only {PRIMITIVE_TYPES} and ENUM supported. Skipping it.")
|
||||
|
||||
return dumped_collection
|
||||
|
||||
@ -122,7 +124,6 @@ def np_dump_collection_primitive(collection: bpy.types.CollectionProperty, attri
|
||||
|
||||
assert(attr_infos.type in ['FLOAT', 'INT', 'BOOLEAN'])
|
||||
|
||||
|
||||
size = sum(attr_infos.array_dimensions) if attr_infos.is_array else 1
|
||||
|
||||
dumped_sequence = np.zeros(
|
||||
@ -395,8 +396,13 @@ class Dumper:
|
||||
if (self.exclude_filter and p in self.exclude_filter) or\
|
||||
(self.include_filter and p not in self.include_filter):
|
||||
return False
|
||||
if not self.accept_read_only and getattr(default, p) and \
|
||||
hasattr(default, "is_property_readonly") and \
|
||||
default.is_property_readonly(p):
|
||||
logging.debug(f"Skipping read only property:{default} - {p}")
|
||||
return False
|
||||
dp = self._dump_any(getattr(default, p), depth)
|
||||
if not (dp is None):
|
||||
if dp:
|
||||
dump[p] = dp
|
||||
return dump
|
||||
|
||||
|
Reference in New Issue
Block a user