refactor: change buffer to data

This commit is contained in:
Swann Martinez 2019-10-07 18:31:49 +02:00
parent 411d77643e
commit 688b57578c
No known key found for this signature in database
GPG Key ID: 414CCAFD8DA720E1
22 changed files with 64 additions and 65 deletions

View File

@ -63,7 +63,7 @@ def client_list_callback(scene, context):
if cli:
client_keys = cli.list(filter=BlUser)
for k in client_keys:
name = cli.get(uuid=k).buffer["name"]
name = cli.get(uuid=k).data["name"]
name_desc = name
if name == username:

View File

@ -51,14 +51,14 @@ class BlAction(BlDatablock):
return data
def resolve(self):
assert(self.buffer)
self.pointer = bpy.data.actions.get(self.buffer['name'])
assert(self.data)
self.pointer = bpy.data.actions.get(self.data['name'])
def diff(self):
return False
def is_valid(self):
return bpy.data.actions.get(self.buffer['name'])
return bpy.data.actions.get(self.data['name'])
bl_id = "actions"
bl_class = bpy.types.Action

View File

@ -89,14 +89,14 @@ class BlArmature(BlDatablock):
return data
def resolve(self):
assert(self.buffer)
self.pointer = bpy.data.armatures.get(self.buffer['name'])
assert(self.data)
self.pointer = bpy.data.armatures.get(self.data['name'])
def diff(self):
False
def is_valid(self):
return bpy.data.armatures.get(self.buffer['name'])
return bpy.data.armatures.get(self.data['name'])
bl_id = "armatures"
bl_class = bpy.types.Armature

View File

@ -48,11 +48,11 @@ class BlCamera(BlDatablock):
return dumper.dump(pointer)
def resolve(self):
assert(self.buffer)
self.pointer = bpy.data.cameras.get(self.buffer['name'])
assert(self.data)
self.pointer = bpy.data.cameras.get(self.data['name'])
def is_valid(self):
return bpy.data.cameras.get(self.buffer['name'])
return bpy.data.cameras.get(self.data['name'])
bl_id = "cameras"

View File

@ -48,8 +48,8 @@ class BlCollection(BlDatablock):
return dumper.dump(pointer)
def resolve(self):
assert(self.buffer)
# self.pointer = bpy.data.collections.get(self.buffer['name'])
assert(self.data)
# self.pointer = bpy.data.collections.get(self.data['name'])
self.pointer = utils.find_from_attr('uuid', self.uuid, bpy.data.collections)
def resolve_dependencies(self):
@ -63,7 +63,7 @@ class BlCollection(BlDatablock):
return deps
def is_valid(self):
return bpy.data.collections.get(self.buffer['name'])
return bpy.data.collections.get(self.data['name'])
bl_id = "collections"
bl_icon = 'FILE_FOLDER'

View File

@ -47,11 +47,11 @@ class BlCurve(BlDatablock):
return data
def resolve(self):
assert(self.buffer)
self.pointer = bpy.data.curves.get(self.buffer['name'])
assert(self.data)
self.pointer = bpy.data.curves.get(self.data['name'])
def is_valid(self):
return bpy.data.curves.get(self.buffer['name'])
return bpy.data.curves.get(self.data['name'])
bl_id = "curves"
bl_class = bpy.types.Curve
bl_rep_class = BlCurve

View File

@ -10,12 +10,11 @@ class BlDatablock(ReplicatedDatablock):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
pointer = kwargs.get('pointer', None)
buffer = self.buffer
# TODO: use is_library_indirect
self.is_library = (pointer and hasattr(pointer, 'library') and
pointer.library) or \
(buffer and 'library' in buffer)
(self.data and 'library' in self.data)
if self.is_library:
self.load = self.load_library
@ -33,7 +32,7 @@ class BlDatablock(ReplicatedDatablock):
def bl_diff(self):
"""Generic datablock diff"""
return self.pointer.name != self.buffer['name']
return self.pointer.name != self.data['name']
def construct_library(self, data):
return None

View File

@ -66,8 +66,8 @@ class BlGpencil(BlDatablock):
return data
def resolve(self):
assert(self.buffer)
self.pointer = bpy.data.grease_pencils.get(self.buffer['name'])
assert(self.data)
self.pointer = bpy.data.grease_pencils.get(self.data['name'])
def resolve_dependencies(self):
deps = []
@ -78,7 +78,7 @@ class BlGpencil(BlDatablock):
return deps
def is_valid(self):
return bpy.data.grease_pencils.get(self.buffer['name'])
return bpy.data.grease_pencils.get(self.data['name'])
bl_id = "grease_pencils"
bl_class = bpy.types.GreasePencil

View File

@ -59,14 +59,14 @@ class BlImage(BlDatablock):
return data
def resolve(self):
assert(self.buffer)
self.pointer = bpy.data.images.get(self.buffer['name'])
assert(self.data)
self.pointer = bpy.data.images.get(self.data['name'])
def diff(self):
return False
def is_valid(self):
return bpy.data.images.get(self.buffer['name'])
return bpy.data.images.get(self.data['name'])
bl_id = "images"
bl_class = bpy.types.Image
bl_rep_class = BlImage

View File

@ -19,14 +19,14 @@ class BlLibrary(BlDatablock):
return utils.dump_datablock(pointer, 1)
def resolve(self):
assert(self.buffer)
self.pointer = bpy.data.libraries.get(self.buffer['name'])
assert(self.data)
self.pointer = bpy.data.libraries.get(self.data['name'])
def diff(self):
return (self.bl_diff())
def is_valid(self):
return bpy.data.libraries.get(self.buffer['name'])
return bpy.data.libraries.get(self.data['name'])
bl_id = "libraries"
bl_class = bpy.types.Library

View File

@ -41,11 +41,11 @@ class BlLight(BlDatablock):
return data
def resolve(self):
assert(self.buffer)
self.pointer = bpy.data.lights.get(self.buffer['name'])
assert(self.data)
self.pointer = bpy.data.lights.get(self.data['name'])
def is_valid(self):
return bpy.data.lights.get(self.buffer['name'])
return bpy.data.lights.get(self.data['name'])
bl_id = "lights"
bl_class = bpy.types.Light

View File

@ -128,8 +128,8 @@ class BlMaterial(BlDatablock):
return data
def resolve(self):
assert(self.buffer)
self.pointer = bpy.data.materials.get(self.buffer['name'])
assert(self.data)
self.pointer = bpy.data.materials.get(self.data['name'])
def resolve_dependencies(self):
# TODO: resolve node group deps
@ -145,7 +145,7 @@ class BlMaterial(BlDatablock):
return deps
def is_valid(self):
return bpy.data.materials.get(self.buffer['name'])
return bpy.data.materials.get(self.data['name'])
bl_id = "materials"

View File

@ -79,7 +79,7 @@ class BlMesh(BlDatablock):
instance = bpy.data.meshes.new(data["name"])
instance.uuid = self.uuid
return instance
def load(self, data, target):
if not target or not target.is_editmode:
# 1 - LOAD MATERIAL SLOTS
@ -155,9 +155,9 @@ class BlMesh(BlDatablock):
return data
def resolve(self):
assert(self.buffer)
assert(self.data)
self.pointer = utils.find_from_attr('uuid', self.uuid, bpy.data.meshes)
# self.pointer = bpy.data.meshes.get(self.buffer['name'])
# self.pointer = bpy.data.meshes.get(self.data['name'])
def resolve_dependencies(self):
deps = []
@ -169,7 +169,7 @@ class BlMesh(BlDatablock):
return deps
def is_valid(self):
return bpy.data.meshes.get(self.buffer['name'])
return bpy.data.meshes.get(self.data['name'])
bl_id = "meshes"
bl_class = bpy.types.Mesh

View File

@ -28,11 +28,11 @@ class BlMetaball(BlDatablock):
return data
def resolve(self):
assert(self.buffer)
self.pointer = bpy.data.metaballs.get(self.buffer['name'])
assert(self.data)
self.pointer = bpy.data.metaballs.get(self.data['name'])
def is_valid(self):
return bpy.data.metaballs.get(self.buffer['name'])
return bpy.data.metaballs.get(self.data['name'])
bl_id = "metaballs"
bl_class = bpy.types.MetaBall

View File

@ -11,11 +11,11 @@ class BlObject(BlDatablock):
pointer = None
if self.is_library:
with bpy.data.libraries.load(filepath=bpy.data.libraries[self.buffer['library']].filepath, link=True) as (sourceData, targetData):
with bpy.data.libraries.load(filepath=bpy.data.libraries[self.data['library']].filepath, link=True) as (sourceData, targetData):
targetData.objects = [
name for name in sourceData.objects if name == self.buffer['name']]
name for name in sourceData.objects if name == self.data['name']]
return targetData.objects[self.buffer['name']]
return targetData.objects[self.data['name']]
# Object specific constructor...
if "data" not in data:
@ -99,9 +99,9 @@ class BlObject(BlDatablock):
return data
def resolve(self):
assert(self.buffer)
assert(self.data)
self.pointer = utils.find_from_attr('uuid', self.uuid, bpy.data.objects)
# object_name = self.buffer['name']
# object_name = self.data['name']
# try:
# self.pointer = bpy.data.objects[object_name]
# except:
@ -122,7 +122,7 @@ class BlObject(BlDatablock):
return deps
def is_valid(self):
return bpy.data.objects.get(self.buffer['name'])
return bpy.data.objects.get(self.data['name'])
bl_id = "objects"

View File

@ -56,8 +56,8 @@ class BlScene(BlDatablock):
return data
def resolve(self):
assert(self.buffer)
scene_name = self.buffer['name']
assert(self.data)
scene_name = self.data['name']
self.pointer = bpy.data.scenes.get(scene_name)
# self.pointer = utils.find_from_attr('uuid', self.uuid, bpy.data.objects)
@ -80,7 +80,7 @@ class BlScene(BlDatablock):
return deps
def is_valid(self):
return bpy.data.scenes.get(self.buffer['name'])
return bpy.data.scenes.get(self.data['name'])
bl_id = "scenes"
bl_class = bpy.types.Scene
bl_rep_class = BlScene

View File

@ -18,7 +18,7 @@ class BlUser(BlDatablock):
def apply(self):
if self.pointer:
self.load(data=self.buffer, target=self.pointer)
self.load(data=self.data, target=self.pointer)
settings = bpy.context.window_manager.session
@ -47,7 +47,7 @@ class BlUser(BlDatablock):
return True
for i,coord in enumerate(self.pointer.location):
if coord != self.buffer['location'][i]:
if coord != self.data['location'][i]:
return True
return False

View File

@ -85,11 +85,11 @@ class BlWorld(BlDatablock):
return data
def resolve(self):
assert(self.buffer)
self.pointer = bpy.data.worlds.get(self.buffer['name'])
assert(self.data)
self.pointer = bpy.data.worlds.get(self.data['name'])
def diff(self):
diff_rev = diff(self.dump(pointer=self.pointer), self.buffer)
diff_rev = diff(self.dump(pointer=self.pointer), self.data)
return (self.bl_diff() or
len(diff_rev.keys()) > 0)
@ -105,7 +105,7 @@ class BlWorld(BlDatablock):
return deps
def is_valid(self):
return bpy.data.worlds.get(self.buffer['name'])
return bpy.data.worlds.get(self.data['name'])
bl_id = "worlds"

View File

@ -128,9 +128,9 @@ class DynamicRightSelectTimer(Timer):
node.uuid, RP_COMMON)
else:
for obj in bpy.data.objects:
if obj.hide_select and obj.name not in user_ref.buffer['selected_objects']:
if obj.hide_select and obj.name not in user_ref.data['selected_objects']:
obj.hide_select = False
elif not obj.hide_select and obj.name in user_ref.buffer['selected_objects']:
elif not obj.hide_select and obj.name in user_ref.data['selected_objects']:
obj.hide_select = True
class Draw(Delayable):
@ -165,10 +165,10 @@ class DrawClient(Draw):
if settings.presence_show_selected:
presence.renderer.draw_client_selection(
cli_ref.buffer['name'], cli_ref.buffer['color'], cli_ref.buffer['selected_objects'])
cli_ref.data['name'], cli_ref.data['color'], cli_ref.data['selected_objects'])
if settings.presence_show_user:
presence.renderer.draw_client_camera(
cli_ref.buffer['name'], cli_ref.buffer['location'], cli_ref.buffer['color'])
cli_ref.data['name'], cli_ref.data['location'], cli_ref.data['color'])
class ClientUpdate(Timer):

@ -1 +1 @@
Subproject commit ef77f6c664bcfb0cb6fddc8e9c89020b88795176
Subproject commit bc6bda2c1d7a5d7852b4bb392c1d2d7fcbe38c4f

View File

@ -259,7 +259,7 @@ class SessionSnapUserOperator(bpy.types.Operator):
target_client = client.get(uuid=self.target_client)
if target_client:
rv3d.view_location = target_client.buffer['location'][0]
rv3d.view_location = target_client.data['location'][0]
rv3d.view_distance = 30.0
return {"FINISHED"}

View File

@ -191,7 +191,7 @@ class SESSION_PT_user(bpy.types.Panel):
for key in client_keys:
area_msg = col.row(align=True)
item_box = area_msg.box()
client = operators.client.get(uuid=key).buffer
client = operators.client.get(uuid=key).data
info = ""
@ -259,7 +259,7 @@ def draw_property(context, parent, property_uuid, level=0):
area_msg.label(text="")
line = area_msg.box()
name = item.buffer['name'] if item.buffer else item.pointer.name
name = item.data['name'] if item.data else item.pointer.name
detail_item_box = line.row(align=True)