refactor: moved get_datablock_from_uuid to bl_datablock
This commit is contained in:
@ -16,14 +16,16 @@
|
|||||||
# ##### END GPL LICENSE BLOCK #####
|
# ##### END GPL LICENSE BLOCK #####
|
||||||
|
|
||||||
|
|
||||||
|
import logging
|
||||||
|
from collections.abc import Iterable
|
||||||
|
|
||||||
import bpy
|
import bpy
|
||||||
import mathutils
|
import mathutils
|
||||||
import logging
|
from replication.constants import DIFF_BINARY, UP
|
||||||
|
from replication.data import ReplicatedDatablock
|
||||||
|
|
||||||
from .. import utils
|
from .. import utils
|
||||||
from .dump_anything import Loader, Dumper
|
from .dump_anything import Dumper, Loader
|
||||||
from replication.data import ReplicatedDatablock
|
|
||||||
from replication.constants import (UP, DIFF_BINARY)
|
|
||||||
|
|
||||||
|
|
||||||
def has_action(target):
|
def has_action(target):
|
||||||
@ -87,6 +89,19 @@ def load_driver(target_datablock, src_driver):
|
|||||||
loader.load(new_point, src_driver['keyframe_points'][src_point])
|
loader.load(new_point, src_driver['keyframe_points'][src_point])
|
||||||
|
|
||||||
|
|
||||||
|
def get_datablock_from_uuid(uuid, default, ignore=[]):
|
||||||
|
if not uuid:
|
||||||
|
return default
|
||||||
|
|
||||||
|
for category in dir(bpy.data):
|
||||||
|
root = getattr(bpy.data, category)
|
||||||
|
if isinstance(root, Iterable) and category not in ignore:
|
||||||
|
for item in root:
|
||||||
|
if getattr(item, 'uuid', None) == uuid:
|
||||||
|
return item
|
||||||
|
return default
|
||||||
|
|
||||||
|
|
||||||
class BlDatablock(ReplicatedDatablock):
|
class BlDatablock(ReplicatedDatablock):
|
||||||
"""BlDatablock
|
"""BlDatablock
|
||||||
|
|
||||||
|
@ -21,9 +21,8 @@ import mathutils
|
|||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from ..utils import get_datablock_from_uuid
|
|
||||||
from .dump_anything import Loader, Dumper
|
from .dump_anything import Loader, Dumper
|
||||||
from .bl_datablock import BlDatablock
|
from .bl_datablock import BlDatablock, get_datablock_from_uuid
|
||||||
|
|
||||||
NODE_SOCKET_INDEX = re.compile('\[(\d*)\]')
|
NODE_SOCKET_INDEX = re.compile('\[(\d*)\]')
|
||||||
|
|
||||||
|
@ -22,7 +22,6 @@ import bpy
|
|||||||
import mathutils
|
import mathutils
|
||||||
from replication.exception import ContextError
|
from replication.exception import ContextError
|
||||||
|
|
||||||
from ..utils import get_datablock_from_uuid
|
|
||||||
from .bl_datablock import BlDatablock
|
from .bl_datablock import BlDatablock
|
||||||
from .dump_anything import Dumper, Loader
|
from .dump_anything import Dumper, Loader
|
||||||
from replication.exception import ReparentException
|
from replication.exception import ReparentException
|
||||||
|
@ -22,7 +22,6 @@ import mathutils
|
|||||||
from .dump_anything import Loader, Dumper
|
from .dump_anything import Loader, Dumper
|
||||||
from .bl_datablock import BlDatablock
|
from .bl_datablock import BlDatablock
|
||||||
from .bl_collection import dump_collection_children, dump_collection_objects, load_collection_childrens, load_collection_objects
|
from .bl_collection import dump_collection_children, dump_collection_objects, load_collection_childrens, load_collection_objects
|
||||||
from ..utils import get_preferences
|
|
||||||
from replication.constants import (DIFF_JSON, MODIFIED)
|
from replication.constants import (DIFF_JSON, MODIFIED)
|
||||||
from deepdiff import DeepDiff
|
from deepdiff import DeepDiff
|
||||||
import logging
|
import logging
|
||||||
|
@ -81,19 +81,6 @@ def resolve_from_id(id, optionnal_type=None):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def get_datablock_from_uuid(uuid, default, ignore=[]):
|
|
||||||
if not uuid:
|
|
||||||
return default
|
|
||||||
|
|
||||||
for category in dir(bpy.data):
|
|
||||||
root = getattr(bpy.data, category)
|
|
||||||
if isinstance(root, Iterable) and category not in ignore:
|
|
||||||
for item in root:
|
|
||||||
if getattr(item, 'uuid', None) == uuid:
|
|
||||||
return item
|
|
||||||
return default
|
|
||||||
|
|
||||||
|
|
||||||
def get_preferences():
|
def get_preferences():
|
||||||
return bpy.context.preferences.addons[__package__].preferences
|
return bpy.context.preferences.addons[__package__].preferences
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user