refactor: get diff back for testing

This commit is contained in:
Swann
2021-05-10 12:04:45 +02:00
parent a67be76422
commit b045911a59
7 changed files with 34 additions and 14 deletions

View File

@ -66,9 +66,11 @@ def register():
environment.setup(DEPENDENCIES, python_binary_path) environment.setup(DEPENDENCIES, python_binary_path)
if LIBS in sys.path: for module_name in list(sys.modules.keys()):
logging.debug('Third party module already added') if 'replication' in module_name:
else: del sys.modules[module_name]
if LIBS not in sys.path:
logging.info('Adding local modules dir to the path') logging.info('Adding local modules dir to the path')
sys.path.insert(0, LIBS) sys.path.insert(0, LIBS)

View File

@ -243,6 +243,6 @@ class BlCurve(BlDatablock):
def diff(self): def diff(self):
if 'EDIT' in bpy.context.mode \ if 'EDIT' in bpy.context.mode \
and not self.preferences.sync_flags.sync_during_editmode: and not self.preferences.sync_flags.sync_during_editmode:
return False return None
else: else:
return super().diff() return super().diff()

View File

@ -135,7 +135,15 @@ class BlFile(ReplicatedDatablock):
return False return False
else: else:
if not self.instance: if not self.instance:
return False return None
if not self.data:
return super().diff()
memory_size = sys.getsizeof(self.data['file'])-33 memory_size = sys.getsizeof(self.data['file'])-33
disk_size = self.instance.stat().st_size disk_size = self.instance.stat().st_size
return memory_size != disk_size
if memory_size != disk_size:
return super().diff()
else:
return None

View File

@ -305,10 +305,11 @@ class BlGpencil(BlDatablock):
return bpy.context.scene.frame_current != self.data["eval_frame"] return bpy.context.scene.frame_current != self.data["eval_frame"]
def diff(self): def diff(self):
if self.layer_changed() \ if not self.data \
or self.layer_changed() \
or self.frame_changed() \ or self.frame_changed() \
or bpy.context.mode == 'OBJECT' \ or bpy.context.mode == 'OBJECT' \
or self.preferences.sync_flags.sync_during_editmode: or self.preferences.sync_flags.sync_during_editmode:
return super().diff() return super().diff()
else: else:
return False return None

View File

@ -99,11 +99,11 @@ class BlImage(BlDatablock):
def diff(self): def diff(self):
if self.instance.is_dirty: if self.instance.is_dirty:
self.instance.save() self.instance.save()
if self.instance and (self.instance.name != self.data['name']): if not self.data or (self.instance and (self.instance.name != self.data['name'])):
return True return super().diff()
else: else:
return False return None
def _resolve_deps_implementation(self): def _resolve_deps_implementation(self):
deps = [] deps = []

View File

@ -555,4 +555,13 @@ class BlScene(BlDatablock):
if not self.preferences.sync_flags.sync_active_camera: if not self.preferences.sync_flags.sync_active_camera:
exclude_path.append("root['camera']") exclude_path.append("root['camera']")
return Delta(DeepDiff(self.data, self._dump(instance=self.instance), exclude_paths=exclude_path)) diff_params = {
'exclude_paths':exclude_path,
'ignore_order':True,
'report_repetition':True
}
delta_params = {
'mutate':True
}
return super().diff(diff_params=diff_params)
# return Delta(DeepDiff(self.data, self._dump(instance=self.instance),))