This repository has been archived by the owner on May 10, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 31
/
models.py
191 lines (141 loc) · 5.16 KB
/
models.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
class QueryResponse:
def __init__(self,answer, json, session):
self.query = json['query']
self.count = json['count']
self.client_id = json['client_id']
self.query_date = json['query_date']
self.answer_time = json['answer_time']
self.session = session
self.answer = answer
def __repr__(self):
return 'QueryResponse (query = %s , count = %s, client_id = %s, ' \
'query_date = %s, answer_time = %s, session = %s, answer = %s )' % \
(self.query, self.count, self.client_id, self.query_date, self.answer_time, self.session, self.answer)
class LoginResponse:
def __init__(self, json, session):
self.message = json['message']
self.session = session
self.valid_seconds = json['valid_seconds']
self.access_token = json['access_token']
def __repr__(self):
return 'LoginResponse: (message = %s, session = %s, valid_seconds = %s, access_token = %s )' % \
(self.message, self.session, self.valid_seconds, self.access_token)
class SignUpResponse:
def __init__(self, json, session):
self.session = session
self.message = json['message']
def __repr__(self):
return 'SignUpResponse: (message = %s, session = %s' % \
(self.message, self.session)
class ForgotPasswordResponse:
def __init__(self, json):
self.message = json['message']
def __repr__(self):
return 'ForgotPasswordResponse: (message = %s)' % self.message
class Answer:
def __init__(self, data, metadata, actions):
self.data = data
self.metadata = metadata
self.actions = actions
def __repr__(self):
return 'Answer: (data = %s, metadata = %s, actions = %s)' % \
(self.data, self.metadata, self.actions)
class Datum:
def __init__(self, json):
# all properties of Datum are exposed as a dictionary rather than by field names
self.values = json
def __repr__(self):
return 'Datum: (values = %s)' % self.values
class Metadata:
def __init__(self, json):
self.count = json['count']
def __repr__(self):
return 'Metadata: (count = %s)' % self.count
class BaseAction:
def __init__(self):
pass
class UnknownAction(BaseAction):
def __init__(self):
super().__init__()
class AnswerAction(BaseAction):
def __init__(self, expression):
super().__init__()
self.expression = expression
class TableAction(BaseAction):
def __init__(self, columns):
super().__init__()
# columns is a dictionary containing list of names of column to be displayed on client.
self.columns = columns
class MapAction(BaseAction):
def __init__(self, latitude, longitude, zoom):
super().__init__()
self.latitude = latitude
self.longitude = longitude
self.zoom = zoom
class AnchorAction(BaseAction):
def __init__(self, link, text):
super().__init__()
self.link = link
self.text = text
class VideoAction(BaseAction):
def __init__(self, identifier , identifier_type):
super().__init__()
self.identifier = identifier
self.identifier_type = identifier_type
class RssAction(BaseAction):
def __init__(self, count, title, description, link):
super().__init__()
self.count = count
self.title = title
self.description = description
self.link = link
class StopAction(BaseAction):
def __init__(self):
super().__init__()
class AudioAction(BaseAction):
def __init__(self, identifier , identifier_type):
super().__init__()
self.identifier = identifier
self.identifier_type = identifier_type
class VolumeAction(BaseAction):
def __init__(self , volume):
super().__init__()
self.volume = volume
class Session:
def __init__(self, identity):
self.identity = identity
def __repr__(self):
return 'Session: (identity = %s)' % self.identity
class Identity:
def __init__(self, json):
self.name = json['name']
self.type = json['type']
self.anonymous = json['anonymous']
def __repr__(self):
return 'Identity: (name = %s, type = %s, anonymous = %s)' % \
(self.name, self.type, self.anonymous)
class Table:
def __init__(self, columns, data):
self.head = list(columns.values())
table_data = []
for datum in data:
table_datum = []
for key in columns.keys():
table_datum.append(datum.values[key])
table_data.append(table_datum)
self.data = table_data
class Map:
def __init__(self, longitude, latitude, zoom=None):
self.longitude = longitude
self.latitude = latitude
if(zoom is None):
self.zoom = 13
else:
self.zoom = zoom
self.openStreetMapLink = 'https://www.openstreetmap.org/#map=%s/%s/%s' % \
(zoom, latitude, longitude)
class RssEntity:
def __init__(self, title, description, link):
self.title = title
self.description = description
self.link = link