-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathListSelect.py
More file actions
73 lines (55 loc) · 1.85 KB
/
Copy pathListSelect.py
File metadata and controls
73 lines (55 loc) · 1.85 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
from typing import List
from DialogFlowPy.Image import Image
from DialogFlowPy.ListItem import ListItem
from DialogFlowPy.SelectOptionInfo import SelectOptionInfo
class ListSelect(dict):
"""
{
'title': string,
'subtitle': string
'items': [
{
object(ListItem)
}
]
}
"""
def __init__(self, title: str, subtitle: str, list_items: List[ListItem]):
super().__init__()
self.list_items = []
for item in list_items:
assert isinstance(item, ListItem)
self.list_items.append(item)
self.title = title
self.subtitle = subtitle
@property
def title(self):
return self.get('title')
@title.setter
def title(self, title: str):
self['title'] = title
@property
def subtitle(self):
return self.get('subtitle')
@subtitle.setter
def subtitle(self, subtitle: str):
self['subtitle'] = subtitle
@property
def list_items(self):
return self.get('items')
@list_items.setter
def list_items(self, items_list):
self['items'] = items_list
def add_list_items(self, list_items: ListItem) -> List[ListItem]:
for item in list_items:
assert isinstance(item, ListItem)
self.list_items.append(item)
return self.list_items
def add_list_item(self, key: str, title: str, description: str = '', image_uri: str = '',
accessibility_text: str = '', synonyms: List[str] = None) -> bool:
if synonyms is None:
synonyms = []
self.list_items.append(ListItem(title=title, description=description, image=Image(
image_uri=image_uri, accessibility_text=accessibility_text),
option_info=SelectOptionInfo(key=key, synonyms=synonyms)))
return True