From fc4fb088bb56e2ebf4b5f1fde68bc0618bd3a09e Mon Sep 17 00:00:00 2001 From: Swann Date: Fri, 4 Jun 2021 14:02:09 +0200 Subject: [PATCH] refactor: repository api clean --- multi_user/libs/replication | 2 +- multi_user/operators.py | 20 ++++++++++---------- multi_user/timers.py | 18 +++++++++--------- multi_user/ui.py | 8 ++++---- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/multi_user/libs/replication b/multi_user/libs/replication index 207c3f4..6c3c18c 160000 --- a/multi_user/libs/replication +++ b/multi_user/libs/replication @@ -1 +1 @@ -Subproject commit 207c3f44e0d31587bcf538ae74d5c6fe2139c1f9 +Subproject commit 6c3c18c2ec6c9bd0af3bec74a3bc0e54803d076d diff --git a/multi_user/operators.py b/multi_user/operators.py index 80ee431..1c85a68 100644 --- a/multi_user/operators.py +++ b/multi_user/operators.py @@ -85,8 +85,8 @@ def initialize_session(): logging.info("Intializing the scene") # Step 1: Constrect nodes logging.info("Instantiating nodes") - for node in session.repository.list_ordered(): - node_ref = session.repository.nodes.get(node) + for node in session.repository.index_sorted: + node_ref = session.repository.graph.get(node) if node_ref is None: logging.error(f"Can't construct node {node}") elif node_ref.state == FETCHED: @@ -97,7 +97,7 @@ def initialize_session(): # Step 2: Load nodes logging.info("Applying nodes") - for node in session.repository.list_ordered(): + for node in session.repository.index_sorted: porcelain.apply(session.repository, node) logging.info("Registering timers") @@ -598,14 +598,14 @@ class SessionApply(bpy.types.Operator): def execute(self, context): logging.debug(f"Running apply on {self.target}") try: - node_ref = session.repository.nodes.get(self.target) + node_ref = session.repository.graph.get(self.target) porcelain.apply(session.repository, self.target, force=True, force_dependencies=self.reset_dependencies) impl = session.repository.rdp.get_implementation(node_ref.instance) if impl.bl_reload_parent: - for parent in session.repository.get_parents(self.target): + for parent in session.repository.graph.get_parents(self.target): logging.debug(f"Refresh parent {parent}") porcelain.apply(session.repository, @@ -801,7 +801,7 @@ class SessionLoadSaveOperator(bpy.types.Operator, ImportHelper): repo.loads(self.filepath) utils.clean_scene() - nodes = [repo.nodes.get(n) for n in repo.list_ordered()] + nodes = [repo.graph.get(n) for n in repo.index_sorted] # Step 1: Construct nodes for node in nodes: @@ -847,9 +847,9 @@ classes = ( def update_external_dependencies(): - nodes_ids = [n.uuid for n in session.repository.nodes.values() if n.data['type_id'] in ['WindowsPath', 'PosixPath']] + nodes_ids = [n.uuid for n in session.repository.graph.values() if n.data['type_id'] in ['WindowsPath', 'PosixPath']] for node_id in nodes_ids: - node = session.repository.nodes.get(node_id) + node = session.repository.graph.get(node_id) if node and node.owner in [session.id, RP_COMMON]: porcelain.commit(session.repository, node_id) porcelain.push(session.repository,'origin', node_id) @@ -861,7 +861,7 @@ def sanitize_deps_graph(remove_nodes: bool = False): if session and session.state == STATE_ACTIVE: start = utils.current_milli_time() rm_cpt = 0 - for node in session.repository.nodes.values(): + for node in session.repository.graph.values(): node.instance = session.repository.rdp.resolve(node.data) if node is None \ or (node.state == UP and not node.instance): @@ -922,7 +922,7 @@ def depsgraph_evaluation(scene): # Is the object tracked ? if update.id.uuid: # Retrieve local version - node = session.repository.nodes.get(update.id.uuid) + node = session.repository.graph.get(update.id.uuid) check_common = session.repository.rdp.get_implementation(update.id).bl_check_common # Check our right on this update: # - if its ours or ( under common and diff), launch the diff --git a/multi_user/timers.py b/multi_user/timers.py index 28b270b..3af27a1 100644 --- a/multi_user/timers.py +++ b/multi_user/timers.py @@ -109,8 +109,8 @@ class SessionListenTimer(Timer): class ApplyTimer(Timer): def execute(self): if session and session.state == STATE_ACTIVE: - for node in session.repository.nodes.keys(): - node_ref = session.repository.nodes.get(node) + for node in session.repository.graph.keys(): + node_ref = session.repository.graph.get(node) if node_ref.state == FETCHED: try: @@ -121,7 +121,7 @@ class ApplyTimer(Timer): else: impl = session.repository.rdp.get_implementation(node_ref.instance) if impl.bl_reload_parent: - for parent in session.repository.get_parents(node): + for parent in session.repository.graph.get_parents(node): logging.debug("Refresh parent {node}") porcelain.apply(session.repository, parent.uuid, @@ -152,7 +152,7 @@ class DynamicRightSelectTimer(Timer): # if an annotation exist and is tracked if annotation_gp and annotation_gp.uuid: - registered_gp = session.repository.nodes.get(annotation_gp.uuid) + registered_gp = session.repository.graph.get(annotation_gp.uuid) if is_annotating(bpy.context): # try to get the right on it if registered_gp.owner == RP_COMMON: @@ -165,7 +165,7 @@ class DynamicRightSelectTimer(Timer): affect_dependencies=False) if registered_gp.owner == settings.username: - gp_node = session.repository.nodes.get(annotation_gp.uuid) + gp_node = session.repository.graph.get(annotation_gp.uuid) porcelain.commit(session.repository, gp_node.uuid) porcelain.push(session.repository, 'origin', gp_node.uuid) @@ -187,7 +187,7 @@ class DynamicRightSelectTimer(Timer): # change old selection right to common for obj in obj_common: - node = session.repository.nodes.get(obj) + node = session.repository.graph.get(obj) if node and (node.owner == settings.username or node.owner == RP_COMMON): recursive = True @@ -204,7 +204,7 @@ class DynamicRightSelectTimer(Timer): # change new selection to our for obj in obj_ours: - node = session.repository.nodes.get(obj) + node = session.repository.graph.get(obj) if node and node.owner == RP_COMMON: recursive = True @@ -233,9 +233,9 @@ class DynamicRightSelectTimer(Timer): # Fix deselection until right managment refactoring (with Roles concepts) if len(current_selection) == 0 : - owned_keys = [k for k, v in session.repository.nodes.items() if v.owner==settings.username] + owned_keys = [k for k, v in session.repository.graph.items() if v.owner==settings.username] for key in owned_keys: - node = session.repository.nodes.get(key) + node = session.repository.graph.get(key) try: porcelain.unlock(session.repository, key, diff --git a/multi_user/ui.py b/multi_user/ui.py index e50cb96..ac9d72c 100644 --- a/multi_user/ui.py +++ b/multi_user/ui.py @@ -438,7 +438,7 @@ class SESSION_PT_presence(bpy.types.Panel): def draw_property(context, parent, property_uuid, level=0): settings = get_preferences() runtime_settings = context.window_manager.session - item = session.repository.nodes.get(property_uuid) + item = session.repository.graph.get(property_uuid) type_id = item.data.get('type_id') area_msg = parent.row(align=True) @@ -548,13 +548,13 @@ class SESSION_PT_repository(bpy.types.Panel): row = box.row() # Properties - owned_nodes = [k for k, v in session.repository.nodes.items() if v.owner==settings.username] + owned_nodes = [k for k, v in session.repository.graph.items() if v.owner==settings.username] - filtered_node = owned_nodes if runtime_settings.filter_owned else session.repository.nodes.keys() + filtered_node = owned_nodes if runtime_settings.filter_owned else session.repository.graph.keys() if runtime_settings.filter_name: for node_id in filtered_node: - node_instance = session.repository.nodes.get(node_id) + node_instance = session.repository.graph.get(node_id) name = node_instance.data.get('name') if runtime_settings.filter_name not in name: filtered_node.remove(node_id)