File tree Expand file tree Collapse file tree 1 file changed +23
-21
lines changed Expand file tree Collapse file tree 1 file changed +23
-21
lines changed Original file line number Diff line number Diff line change @@ -241,28 +241,30 @@ def get_path(string_path):
241
241
return path , string_path
242
242
243
243
244
+ def record_value_to_comparable (val , func = None , rel = False ):
245
+ def get_val (v ):
246
+ if func is not None :
247
+ return Value (func (v )[0 ])
248
+ else :
249
+ return Value (v )
250
+
251
+ if val == 'null' :
252
+ return Value (None )
253
+ if isinstance (val , compat .string ) and val [0 ] == '[' :
254
+ if not rel or (rel and val [1 ] == '[' ):
255
+ val = val [1 :- 1 ].split (", " )
256
+ if isinstance (val ,list ):
257
+ return tuple ([get_val (v ) for v in val ])
258
+ else :
259
+ return get_val (val )
260
+
244
261
def result_to_set (result , func = None , rel = False ):
245
- s = set ([])
246
- for row in result :
247
- l = []
248
- for i ,_ in enumerate (row ):
249
- cell = row [i ]
250
- if cell == 'null' :
251
- cell = None
252
- if isinstance (cell , compat .string ) and cell [0 ] == '[' :
253
- if rel and cell [1 ] != '[' :
254
- cell = [cell ]
255
- else :
256
- cell = cell [1 :- 1 ].split (", " )
257
- if not isinstance (cell ,list ):
258
- cell = [cell ]
259
- if func is not None :
260
- cell = [Value (func (val )[0 ]) for val in cell ]
261
- else :
262
- cell = [Value (val ) for val in cell ]
263
- l .append (tuple (cell ))
264
- s .add (tuple (l ))
265
- return s
262
+ records = set ([])
263
+ for record in result :
264
+ for i ,_ in enumerate (record ):
265
+ cell = record_value_to_comparable (record [i ], func , rel )
266
+ records .add (cell )
267
+ return records
266
268
267
269
268
270
def text_path_to_set (table ):
You can’t perform that action at this time.
0 commit comments