-
Notifications
You must be signed in to change notification settings - Fork 7
/
custom_actions.py
31 lines (23 loc) · 948 Bytes
/
custom_actions.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
class CustomActions():
sufix = ["Exit"]
def __init__(self, operation):
self.prefixes = ["..", "Open in Browser", "Create " + operation.trello_element_name()]
self.prefix_methods = [operation.go_back, operation.open_in_browser, operation.get_name]
def encapsulate(self, data):
return self.prefixes + data + self.sufix
def call(self, index):
return self.prefix_methods[index]()
def has(self, index):
return self.len() > index and index >= 0
def len(self):
return len(self.prefixes)
def add(self, prefix, method):
self.prefixes.append(prefix)
self.prefix_methods.append(method)
def rename(self, old_name, new_name):
index = self.prefixes.index(old_name)
self.prefixes[index] = new_name
def remove(self, name):
index = self.prefixes.index(name)
self.prefixes.pop(index)
self.prefix_methods.pop(index)