1616# specific language governing permissions and limitations
1717# under the License.
1818#
19-
2019from datetime import datetime
2120
2221import grakn_protocol .protobuf .concept_pb2 as concept_proto
@@ -77,13 +76,13 @@ def is_datetime(self):
7776
7877class BooleanAttribute (Attribute ):
7978
80- def __init__ (self , iid : str , value : bool ):
81- super (BooleanAttribute , self ).__init__ (iid )
79+ def __init__ (self , iid : str , type_ , value : bool ):
80+ super (BooleanAttribute , self ).__init__ (iid , type_ )
8281 self ._value = value
8382
8483 @staticmethod
8584 def _of (thing_proto : concept_proto .Thing ):
86- return BooleanAttribute (concept_proto_reader .iid (thing_proto .iid ), thing_proto .value .boolean )
85+ return BooleanAttribute (concept_proto_reader .iid (thing_proto .iid ), concept_proto_reader . attribute_type ( thing_proto . type ), thing_proto .value .boolean )
8786
8887 def get_value (self ):
8988 return self ._value
@@ -92,13 +91,13 @@ def is_boolean(self):
9291 return True
9392
9493 def as_remote (self , transaction ):
95- return RemoteBooleanAttribute (transaction , self .get_iid (), self .get_value ())
94+ return RemoteBooleanAttribute (transaction , self .get_iid (), self .get_type (), self . get_value ())
9695
9796
9897class RemoteBooleanAttribute (RemoteAttribute ):
9998
100- def __init__ (self , transaction , iid : str , value : bool ):
101- super (RemoteBooleanAttribute , self ).__init__ (transaction , iid )
99+ def __init__ (self , transaction , iid : str , type_ , value : bool ):
100+ super (RemoteBooleanAttribute , self ).__init__ (transaction , iid , type_ )
102101 self ._value = value
103102
104103 def get_value (self ):
@@ -108,18 +107,18 @@ def is_boolean(self):
108107 return True
109108
110109 def as_remote (self , transaction ):
111- return RemoteBooleanAttribute (transaction , self .get_iid (), self .get_value ())
110+ return RemoteBooleanAttribute (transaction , self .get_iid (), self .get_type (), self . get_value ())
112111
113112
114113class LongAttribute (Attribute ):
115114
116- def __init__ (self , iid : str , value : int ):
117- super (LongAttribute , self ).__init__ (iid )
115+ def __init__ (self , iid : str , type_ , value : int ):
116+ super (LongAttribute , self ).__init__ (iid , type_ )
118117 self ._value = value
119118
120119 @staticmethod
121120 def _of (thing_proto : concept_proto .Thing ):
122- return LongAttribute (concept_proto_reader .iid (thing_proto .iid ), thing_proto .value .long )
121+ return LongAttribute (concept_proto_reader .iid (thing_proto .iid ), concept_proto_reader . attribute_type ( thing_proto . type ), thing_proto .value .long )
123122
124123 def get_value (self ):
125124 return self ._value
@@ -128,13 +127,13 @@ def is_long(self):
128127 return True
129128
130129 def as_remote (self , transaction ):
131- return RemoteLongAttribute (transaction , self .get_iid (), self .get_value ())
130+ return RemoteLongAttribute (transaction , self .get_iid (), self .get_type (), self . get_value ())
132131
133132
134133class RemoteLongAttribute (RemoteAttribute ):
135134
136- def __init__ (self , transaction , iid : str , value : int ):
137- super (RemoteLongAttribute , self ).__init__ (transaction , iid )
135+ def __init__ (self , transaction , iid : str , type_ , value : int ):
136+ super (RemoteLongAttribute , self ).__init__ (transaction , iid , type_ )
138137 self ._value = value
139138
140139 def get_value (self ):
@@ -144,18 +143,18 @@ def is_long(self):
144143 return True
145144
146145 def as_remote (self , transaction ):
147- return RemoteLongAttribute (transaction , self .get_iid (), self .get_value ())
146+ return RemoteLongAttribute (transaction , self .get_iid (), self .get_type (), self . get_value ())
148147
149148
150149class DoubleAttribute (Attribute ):
151150
152- def __init__ (self , iid : str , value : float ):
153- super (DoubleAttribute , self ).__init__ (iid )
151+ def __init__ (self , iid : str , type_ , value : float ):
152+ super (DoubleAttribute , self ).__init__ (iid , type_ )
154153 self ._value = value
155154
156155 @staticmethod
157156 def _of (thing_proto : concept_proto .Thing ):
158- return DoubleAttribute (concept_proto_reader .iid (thing_proto .iid ), thing_proto .value .double )
157+ return DoubleAttribute (concept_proto_reader .iid (thing_proto .iid ), concept_proto_reader . attribute_type ( thing_proto . type ), thing_proto .value .double )
159158
160159 def get_value (self ):
161160 return self ._value
@@ -164,13 +163,13 @@ def is_double(self):
164163 return True
165164
166165 def as_remote (self , transaction ):
167- return RemoteDoubleAttribute (transaction , self .get_iid (), self .get_value ())
166+ return RemoteDoubleAttribute (transaction , self .get_iid (), self .get_type (), self . get_value ())
168167
169168
170169class RemoteDoubleAttribute (RemoteAttribute ):
171170
172- def __init__ (self , transaction , iid : str , value : float ):
173- super (RemoteDoubleAttribute , self ).__init__ (transaction , iid )
171+ def __init__ (self , transaction , iid : str , type_ , value : float ):
172+ super (RemoteDoubleAttribute , self ).__init__ (transaction , iid , type_ )
174173 self ._value = value
175174
176175 def get_value (self ):
@@ -180,18 +179,18 @@ def is_double(self):
180179 return True
181180
182181 def as_remote (self , transaction ):
183- return RemoteDoubleAttribute (transaction , self .get_iid (), self .get_value ())
182+ return RemoteDoubleAttribute (transaction , self .get_iid (), self .get_type (), self . get_value ())
184183
185184
186185class StringAttribute (Attribute ):
187186
188- def __init__ (self , iid : str , value : str ):
189- super (StringAttribute , self ).__init__ (iid )
187+ def __init__ (self , iid : str , type_ , value : str ):
188+ super (StringAttribute , self ).__init__ (iid , type_ )
190189 self ._value = value
191190
192191 @staticmethod
193192 def _of (thing_proto : concept_proto .Thing ):
194- return StringAttribute (concept_proto_reader .iid (thing_proto .iid ), thing_proto .value .string )
193+ return StringAttribute (concept_proto_reader .iid (thing_proto .iid ), concept_proto_reader . attribute_type ( thing_proto . type ), thing_proto .value .string )
195194
196195 def get_value (self ):
197196 return self ._value
@@ -200,13 +199,13 @@ def is_string(self):
200199 return True
201200
202201 def as_remote (self , transaction ):
203- return RemoteStringAttribute (transaction , self .get_iid (), self .get_value ())
202+ return RemoteStringAttribute (transaction , self .get_iid (), self .get_type (), self . get_value ())
204203
205204
206205class RemoteStringAttribute (RemoteAttribute ):
207206
208- def __init__ (self , transaction , iid : str , value : str ):
209- super (RemoteStringAttribute , self ).__init__ (transaction , iid )
207+ def __init__ (self , transaction , iid : str , type_ , value : str ):
208+ super (RemoteStringAttribute , self ).__init__ (transaction , iid , type_ )
210209 self ._value = value
211210
212211 def get_value (self ):
@@ -216,18 +215,18 @@ def is_string(self):
216215 return True
217216
218217 def as_remote (self , transaction ):
219- return RemoteStringAttribute (transaction , self .get_iid (), self .get_value ())
218+ return RemoteStringAttribute (transaction , self .get_iid (), self .get_type (), self . get_value ())
220219
221220
222221class DateTimeAttribute (Attribute ):
223222
224- def __init__ (self , iid : str , value : datetime ):
225- super (DateTimeAttribute , self ).__init__ (iid )
223+ def __init__ (self , iid : str , type_ , value : datetime ):
224+ super (DateTimeAttribute , self ).__init__ (iid , type_ )
226225 self ._value = value
227226
228227 @staticmethod
229228 def _of (thing_proto : concept_proto .Thing ):
230- return DateTimeAttribute (concept_proto_reader .iid (thing_proto .iid ), datetime .fromtimestamp (float (thing_proto .value .date_time ) / 1000.0 ))
229+ return DateTimeAttribute (concept_proto_reader .iid (thing_proto .iid ), concept_proto_reader . attribute_type ( thing_proto . type ), datetime .fromtimestamp (float (thing_proto .value .date_time ) / 1000.0 ))
231230
232231 def get_value (self ):
233232 return self ._value
@@ -236,13 +235,13 @@ def is_datetime(self):
236235 return True
237236
238237 def as_remote (self , transaction ):
239- return RemoteDateTimeAttribute (transaction , self .get_iid (), self .get_value ())
238+ return RemoteDateTimeAttribute (transaction , self .get_iid (), self .get_type (), self . get_value ())
240239
241240
242241class RemoteDateTimeAttribute (RemoteAttribute ):
243242
244- def __init__ (self , transaction , iid : str , value : datetime ):
245- super (RemoteDateTimeAttribute , self ).__init__ (transaction , iid )
243+ def __init__ (self , transaction , iid : str , type_ , value : datetime ):
244+ super (RemoteDateTimeAttribute , self ).__init__ (transaction , iid , type_ )
246245 self ._value = value
247246
248247 def get_value (self ):
@@ -252,4 +251,4 @@ def is_datetime(self):
252251 return True
253252
254253 def as_remote (self , transaction ):
255- return RemoteDateTimeAttribute (transaction , self .get_iid (), self .get_value ())
254+ return RemoteDateTimeAttribute (transaction , self .get_iid (), self .get_type (), self . get_value ())
0 commit comments