Lines Matching refs:self

34   def __init__(self, simg_fn, file_map_fn=None, clobbered_blocks=None):  argument
35 self.simg_f = f = open(simg_fn, "rb")
45 self.blocksize = blk_sz = header[5]
46 self.total_blocks = total_blks = header[6]
66 self.offset_map = offset_map = []
67 self.clobbered_blocks = rangelib.RangeSet(data=clobbered_blocks)
110 self.care_map = rangelib.RangeSet(care_data)
111 self.offset_index = [i[0] for i in offset_map]
119 extended = self.care_map.extend(512)
120 all_blocks = rangelib.RangeSet(data=(0, self.total_blocks))
121 extended = extended.intersect(all_blocks).subtract(self.care_map)
122 self.extended = extended
125 self.LoadFileBlockMap(file_map_fn, self.clobbered_blocks)
127 self.file_map = {"__DATA": self.care_map}
129 def ReadRangeSet(self, ranges): argument
130 return [d for d in self._GetRangeData(ranges)]
132 def TotalSha1(self, include_clobbered_blocks=False): argument
137 ranges = self.care_map
139 ranges = ranges.subtract(self.clobbered_blocks)
141 for d in self._GetRangeData(ranges):
145 def _GetRangeData(self, ranges): argument
155 f = self.simg_f
158 idx = bisect.bisect_right(self.offset_index, s) - 1
159 chunk_start, chunk_len, filepos, fill_data = self.offset_map[idx]
165 p = filepos + ((s - chunk_start) * self.blocksize)
167 yield f.read(this_read * self.blocksize)
169 yield fill_data * (this_read * (self.blocksize >> 2))
175 chunk_start, chunk_len, filepos, fill_data = self.offset_map[idx]
179 yield f.read(this_read * self.blocksize)
181 yield fill_data * (this_read * (self.blocksize >> 2))
184 def LoadFileBlockMap(self, fn, clobbered_blocks): argument
185 remaining = self.care_map
186 self.file_map = out = {}
211 reference = '\0' * self.blocksize
213 f = self.simg_f
216 idx = bisect.bisect_right(self.offset_index, b) - 1
217 chunk_start, _, filepos, fill_data = self.offset_map[idx]
219 filepos += (b-chunk_start) * self.blocksize
221 data = f.read(self.blocksize)
244 def ResetFileMap(self): argument
247 self.file_map = {"__DATA": self.care_map}