@@ -1179,32 +1179,24 @@ def find(cls, *expressions: Union[Any, Expression]) -> FindQuery:
1179
1179
@classmethod
1180
1180
def from_redis (cls , res : Any ):
1181
1181
# TODO: Parsing logic copied from redisearch-py. Evaluate.
1182
- import six
1183
- from six .moves import xrange
1184
- from six .moves import zip as izip
1185
-
1186
1182
def to_string (s ):
1187
- if isinstance (s , six . string_types ):
1183
+ if isinstance (s , ( str ,) ):
1188
1184
return s
1189
- elif isinstance (s , six . binary_type ):
1190
- return s .decode ("utf-8" , " ignore" )
1185
+ elif isinstance (s , bytes ):
1186
+ return s .decode ("ignore" )
1191
1187
else :
1192
1188
return s # Not a string we care about
1193
1189
1194
1190
docs = []
1195
1191
step = 2 # Because the result has content
1196
1192
offset = 1 # The first item is the count of total matches.
1197
1193
1198
- for i in xrange (1 , len (res ), step ):
1199
- fields_offset = offset
1200
-
1194
+ for i in range (1 , len (res ), step ):
1201
1195
fields = dict (
1202
- dict (
1203
- izip (
1204
- map (to_string , res [i + fields_offset ][::2 ]),
1205
- map (to_string , res [i + fields_offset ][1 ::2 ]),
1196
+ zip (
1197
+ map (to_string , res [i + offset ][::2 ]),
1198
+ map (to_string , res [i + offset ][1 ::2 ]),
1206
1199
)
1207
- )
1208
1200
)
1209
1201
1210
1202
try :
@@ -1218,6 +1210,7 @@ def to_string(s):
1218
1210
doc = cls (** json_fields )
1219
1211
else :
1220
1212
doc = cls (** fields )
1213
+
1221
1214
docs .append (doc )
1222
1215
return docs
1223
1216
0 commit comments