refactor: remove list

This commit is contained in:
Swann 2021-06-04 12:07:54 +02:00
parent 569543650f
commit 1e15a12b10
No known key found for this signature in database
GPG Key ID: E1D3641A7C43AACB
4 changed files with 13 additions and 55 deletions

@ -1 +1 @@
Subproject commit a40741185955a8f8700f4ebeb14d4d83e3186718
Subproject commit d3b998789fd5c8696a21e0ef8ffae80c1024beba

View File

@ -105,7 +105,6 @@ def initialize_session():
for d in deleyables:
d.register()
bpy.ops.session.apply_armature_operator('INVOKE_DEFAULT')
# Step 5: Clearing history
utils.flush_history()
@ -641,48 +640,6 @@ class SessionCommit(bpy.types.Operator):
self.report({'ERROR'}, repr(e))
return {"CANCELLED"}
class ApplyArmatureOperator(bpy.types.Operator):
"""Operator which runs its self from a timer"""
bl_idname = "session.apply_armature_operator"
bl_label = "Modal Executor Operator"
_timer = None
def modal(self, context, event):
global stop_modal_executor, modal_executor_queue
if stop_modal_executor:
self.cancel(context)
return {'CANCELLED'}
if event.type == 'TIMER':
if session and session.state == STATE_ACTIVE:
nodes = session.list(filter=bl_types.bl_armature.BlArmature)
for node in nodes:
node_ref = session.repository.get_node(node)
if node_ref.state == FETCHED:
try:
porcelain.apply(session.repository, node)
except Exception as e:
logging.error("Fail to apply armature: {e}")
return {'PASS_THROUGH'}
def execute(self, context):
wm = context.window_manager
self._timer = wm.event_timer_add(2, window=context.window)
wm.modal_handler_add(self)
return {'RUNNING_MODAL'}
def cancel(self, context):
global stop_modal_executor
wm = context.window_manager
wm.event_timer_remove(self._timer)
stop_modal_executor = False
class SessionClearCache(bpy.types.Operator):
"Clear local session cache"
@ -712,6 +669,7 @@ class SessionClearCache(bpy.types.Operator):
row = self.layout
row.label(text=f" Do you really want to remove local cache ? ")
class SessionPurgeOperator(bpy.types.Operator):
"Remove node with lost references"
bl_idname = "session.purge"
@ -802,6 +760,7 @@ class SessionSaveBackupOperator(bpy.types.Operator, ExportHelper):
def poll(cls, context):
return session.state == STATE_ACTIVE
class SessionStopAutoSaveOperator(bpy.types.Operator):
bl_idname = "session.cancel_autosave"
bl_label = "Cancel auto-save"
@ -862,6 +821,7 @@ class SessionLoadSaveOperator(bpy.types.Operator, ImportHelper):
def poll(cls, context):
return True
def menu_func_import(self, context):
self.layout.operator(SessionLoadSaveOperator.bl_idname, text='Multi-user session snapshot (.db)')
@ -875,7 +835,6 @@ classes = (
SessionPropertyRightOperator,
SessionApply,
SessionCommit,
ApplyArmatureOperator,
SessionKickOperator,
SessionInitOperator,
SessionClearCache,
@ -886,22 +845,23 @@ classes = (
SessionPurgeOperator,
)
def update_external_dependencies():
nodes_ids = session.list(filter=bl_types.bl_file.BlFile)
nodes_ids = [n.uuid for n in session.repository.nodes.values() if n.data['type_id'] in ['WindowsPath', 'PosixPath']]
for node_id in nodes_ids:
node = session.repository.get_node(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)
def sanitize_deps_graph(remove_nodes: bool = False):
""" Cleanup the replication graph
"""
if session and session.state == STATE_ACTIVE:
start = utils.current_milli_time()
rm_cpt = 0
for node_key in session.list():
node = session.repository.get_node(node_key)
for node in session.repository.nodes.values():
node.instance = session.repository.rdp.resolve(node.data)
if node is None \
or (node.state == UP and not node.instance):
@ -928,6 +888,7 @@ def resolve_deps_graph(dummy):
if session and session.state == STATE_ACTIVE:
sanitize_deps_graph(remove_nodes=True)
@persistent
def load_pre_handler(dummy):
if session and session.state in [STATE_ACTIVE, STATE_SYNCING]:

View File

@ -109,9 +109,7 @@ class SessionListenTimer(Timer):
class ApplyTimer(Timer):
def execute(self):
if session and session.state == STATE_ACTIVE:
nodes = session.list()
for node in nodes:
for node in session.repository.nodes.keys():
node_ref = session.repository.get_node(node)
if node_ref.state == FETCHED:
@ -235,7 +233,7 @@ class DynamicRightSelectTimer(Timer):
# Fix deselection until right managment refactoring (with Roles concepts)
if len(current_selection) == 0 :
owned_keys = session.list(filter_owner=settings.username)
owned_keys = [k for k, v in session.repository.nodes.items() if v.owner==settings.username]
for key in owned_keys:
node = session.repository.get_node(key)
try:

View File

@ -548,10 +548,9 @@ class SESSION_PT_repository(bpy.types.Panel):
row = box.row()
# Properties
types_filter = [t.type_name for t in settings.supported_datablocks
if t.use_as_filter]
owned_nodes = [k for k, v in session.repository.nodes.items() if v.owner==settings.username]
filtered_node = session.list(filter_owner=settings.username) if runtime_settings.filter_owned else session.list()
filtered_node = owned_nodes if runtime_settings.filter_owned else session.repository.nodes.keys()
if runtime_settings.filter_name:
for node_id in filtered_node: