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
|
properties = collection[0].bl_rna.properties
|
||||||
|
|
||||||
if attributes is None:
|
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:
|
for attr in attributes:
|
||||||
attr_type = properties[attr].type
|
attr_type = properties[attr].type
|
||||||
@ -97,7 +98,8 @@ def np_dump_collection(collection: bpy.types.CollectionProperty, attributes: lis
|
|||||||
elif attr_type == 'ENUM':
|
elif attr_type == 'ENUM':
|
||||||
dumped_collection[attr] = np_dump_collection_enum(collection, attr)
|
dumped_collection[attr] = np_dump_collection_enum(collection, attr)
|
||||||
else:
|
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
|
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'])
|
assert(attr_infos.type in ['FLOAT', 'INT', 'BOOLEAN'])
|
||||||
|
|
||||||
|
|
||||||
size = sum(attr_infos.array_dimensions) if attr_infos.is_array else 1
|
size = sum(attr_infos.array_dimensions) if attr_infos.is_array else 1
|
||||||
|
|
||||||
dumped_sequence = np.zeros(
|
dumped_sequence = np.zeros(
|
||||||
@ -395,8 +396,13 @@ class Dumper:
|
|||||||
if (self.exclude_filter and p in self.exclude_filter) or\
|
if (self.exclude_filter and p in self.exclude_filter) or\
|
||||||
(self.include_filter and p not in self.include_filter):
|
(self.include_filter and p not in self.include_filter):
|
||||||
return False
|
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)
|
dp = self._dump_any(getattr(default, p), depth)
|
||||||
if not (dp is None):
|
if dp:
|
||||||
dump[p] = dp
|
dump[p] = dp
|
||||||
return dump
|
return dump
|
||||||
|
|
||||||
@ -538,7 +544,7 @@ class Loader:
|
|||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
_constructor_parameters = [dumped_element[name]
|
_constructor_parameters = [dumped_element[name]
|
||||||
for name in _constructor[1]]
|
for name in _constructor[1]]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
logging.debug("Collection load error, missing parameters.")
|
logging.debug("Collection load error, missing parameters.")
|
||||||
continue # TODO handle error
|
continue # TODO handle error
|
||||||
|
Reference in New Issue
Block a user