@@ -116,19 +116,17 @@ def read(self, symbol, chunk_range=None):
116
116
"""
117
117
118
118
sym = self ._get_symbol_info (symbol )
119
-
120
119
if not sym :
121
120
raise NoDataFoundException ('No data found for %s in library %s' % (symbol , self ._collection .get_name ()))
122
121
123
122
spec = {'symbol' : symbol ,
124
123
}
125
124
126
- if chunk_range is not None :
125
+ if chunk_range :
127
126
spec ['start' ] = self .chunker .to_mongo (chunk_range )
128
127
129
128
segments = []
130
- i = - 1
131
- for i , x in enumerate (self ._collection .find (spec , sort = [('start' , pymongo .ASCENDING )],)):
129
+ for _ , x in enumerate (self ._collection .find (spec , sort = [('start' , pymongo .ASCENDING )],)):
132
130
segments .append (decompress (x ['data' ]))
133
131
134
132
data = b'' .join (segments )
@@ -169,10 +167,9 @@ def write(self, symbol, item, chunk_size):
169
167
170
168
previous_shas = []
171
169
if self ._get_symbol_info (symbol ):
172
- previous_shas = set ([x ['sha' ] for x in self ._collection .find ({'symbol' : symbol },
170
+ previous_shas = set ([Binary ( x ['sha' ]) for x in self ._collection .find ({'symbol' : symbol },
173
171
projection = {'sha' : True , '_id' : False },
174
172
)])
175
-
176
173
records = []
177
174
ranges = []
178
175
dtype = None
@@ -205,6 +202,7 @@ def write(self, symbol, item, chunk_size):
205
202
chunk ['end' ] = end
206
203
chunk ['symbol' ] = symbol
207
204
chunk ['sha' ] = checksum (symbol , chunk )
205
+
208
206
if chunk ['sha' ] not in previous_shas :
209
207
op = True
210
208
bulk .find ({'symbol' : symbol , 'sha' : chunk ['sha' ]},
0 commit comments