refactor: repository api clean

This commit is contained in:
Swann 2021-06-04 14:02:09 +02:00
parent 98553ba00c
commit fc4fb088bb
No known key found for this signature in database
GPG Key ID: E1D3641A7C43AACB
4 changed files with 24 additions and 24 deletions

@ -1 +1 @@
Subproject commit 207c3f44e0d31587bcf538ae74d5c6fe2139c1f9
Subproject commit 6c3c18c2ec6c9bd0af3bec74a3bc0e54803d076d

View File

@ -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

View File

@ -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,

View File

@ -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)