• Home
  • Raw
  • Download

Lines Matching refs:self

43   def __init__(self, simg_fn, file_map_fn=None, clobbered_blocks=None,  argument
46 self.simg_f = f = open(simg_fn, mode)
56 self.blocksize = blk_sz = header[5]
57 self.total_blocks = total_blks = header[6]
58 self.total_chunks = total_chunks = header[7]
83 self.offset_map = offset_map = []
84 self.clobbered_blocks = rangelib.RangeSet(data=clobbered_blocks)
137 self.generator_lock = threading.Lock()
139 self.care_map = rangelib.RangeSet(care_data)
140 self.offset_index = [i[0] for i in offset_map]
148 extended = self.care_map.extend(512)
149 all_blocks = rangelib.RangeSet(data=(0, self.total_blocks))
150 extended = extended.intersect(all_blocks).subtract(self.care_map)
151 self.extended = extended
153 self.hashtree_info = None
155 self.hashtree_info = hashtree_info_generator.Generate(self)
158 self.LoadFileBlockMap(file_map_fn, self.clobbered_blocks,
161 self.file_map = {"__DATA": self.care_map}
163 def AppendFillChunk(self, data, blocks): argument
164 f = self.simg_f
171 self.total_blocks += blocks
172 self.total_chunks += 1
175 f.write(struct.pack("<2I", self.total_blocks, self.total_chunks))
177 def RangeSha1(self, ranges): argument
179 for data in self._GetRangeData(ranges):
183 def ReadRangeSet(self, ranges): argument
184 return [d for d in self._GetRangeData(ranges)]
186 def TotalSha1(self, include_clobbered_blocks=False): argument
191 ranges = self.care_map
193 ranges = ranges.subtract(self.clobbered_blocks)
194 return self.RangeSha1(ranges)
196 def WriteRangeDataToFd(self, ranges, fd): argument
197 for data in self._GetRangeData(ranges):
200 def _GetRangeData(self, ranges): argument
209 f = self.simg_f
210 with self.generator_lock:
213 idx = bisect.bisect_right(self.offset_index, s) - 1
214 chunk_start, chunk_len, filepos, fill_data = self.offset_map[idx]
220 p = filepos + ((s - chunk_start) * self.blocksize)
222 yield f.read(this_read * self.blocksize)
224 yield fill_data * (this_read * (self.blocksize >> 2))
230 chunk_start, chunk_len, filepos, fill_data = self.offset_map[idx]
234 yield f.read(this_read * self.blocksize)
236 yield fill_data * (this_read * (self.blocksize >> 2))
239 def LoadFileBlockMap(self, fn, clobbered_blocks, allow_shared_blocks): argument
247 remaining = self.care_map
248 self.file_map = out = {}
281 if self.hashtree_info:
282 remaining = remaining.subtract(self.hashtree_info.hashtree_range)
293 reference = '\0' * self.blocksize
305 f = self.simg_f
308 idx = bisect.bisect_right(self.offset_index, b) - 1
309 chunk_start, _, filepos, fill_data = self.offset_map[idx]
311 filepos += (b-chunk_start) * self.blocksize
313 data = f.read(self.blocksize)
345 if self.hashtree_info:
346 out["__HASHTREE"] = self.hashtree_info.hashtree_range
348 def ResetFileMap(self): argument
351 self.file_map = {"__DATA": self.care_map}