-
Notifications
You must be signed in to change notification settings - Fork 4
/
utils.py
53 lines (39 loc) · 1.4 KB
/
utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import bpy
def list_interection(lst1, lst2):
"""return common elements of two lists"""
return set(lst1).intersection(lst2)
def list_have_common_elements(lst1, lst2):
"""return if two lists have common elements"""
return bool(list_interection(lst1, lst2))
class RunningOperator(bpy.types.Operator):
"""base class used by exectracker/benchmarker operators"""
bl_idname = ""
bl_label = ""
bl_description = ""
bl_options = {'INTERNAL'}
is_running = False
@classmethod
def get_infos(cls):
"""operator ui might differ if operator is running in background or not
return (is_running, Start/Stop name, PAUSE/PLAY icon)"""
if cls.is_running:
return (cls.is_running, "Stop", "PAUSE")
else: return (cls.is_running, "Start", "PLAY")
@classmethod
def running_status(cls, setter:bool=None):
if (setter is None):
return cls.is_running
cls.is_running = setter
return None
def execute(self, context):
if (self.running_status()==True):
self.end()
self.running_status(setter=False)
else:
self.running_status(setter=True)
self.start()
return {'FINISHED'}
def start(self):
pass #children defined
def end(self):
pass #children defined