def deserializeToObject(cls, serializedObject, parentObject):
"""see Score.deserializeToObject."""
#TODO: this is nearly the same as the GraphBlock method with the same name. During development it made sense to write to different functions. But this can be simplified by calling super().deserializeToObject
assert cls.__name__ == serializedObject["class"]
self = cls.__new__(cls)
if serializedObject["data"] is None:
firstBlock = TempoBlock.firstBlockWithNewContentDuringDeserializeToObject[serializedObject["contentLinkGroup"]] #first block with the same contentGroup. This is the one with the real data.
self.data = firstBlock.data
self._duration = firstBlock._duration
self.linkedContentBlocks = firstBlock.linkedContentBlocks #add self to this is in _secondInit
else: #Standalone or First occurence of a content linked block
self.data = {int(position):eval(item["class"]).deserializeToObject(item, parentObject = self) for position, item in serializedObject["data"].items()}
TempoBlock.firstBlockWithNewContentDuringDeserializeToObject[serializedObject["contentLinkGroup"]] = self
self._duration = [int(serializedObject["duration"])] #this is just an int, minimumBlockInTicks or so. Not Item.Duration(). For save and load we drop the list as mutable value.
self.linkedContentBlocks = WeakSet()
#No super() deserialize call here so we need to create all objects directly:
self.name = serializedObject["name"]
self._secondInit(parentObject)
return self
评论列表
文章目录