Lines Matching refs:self
27 def __init__(self): argument
28 self.blocks_stashed = 0
29 self.overlap_blocks_stashed = 0
30 self.max_stash_needed = 0
31 self.current_stash_size = 0
32 self.stash_map = {}
34 def StashBlocks(self, SHA1, blocks): argument
35 if SHA1 in self.stash_map:
38 self.blocks_stashed += blocks.size()
39 self.current_stash_size += blocks.size()
40 self.max_stash_needed = max(self.current_stash_size, self.max_stash_needed)
41 self.stash_map[SHA1] = blocks
43 def FreeBlocks(self, SHA1): argument
44 assert self.stash_map.has_key(SHA1), "stash {} not found".format(SHA1)
45 self.current_stash_size -= self.stash_map[SHA1].size()
46 del self.stash_map[SHA1]
48 def HandleOverlapBlocks(self, SHA1, blocks): argument
49 self.StashBlocks(SHA1, blocks)
50 self.overlap_blocks_stashed += blocks.size()
51 self.FreeBlocks(SHA1)
57 def __init__(self, package): argument
58 self.package = package
59 self.new_data_size = 0
60 self.patch_data_size = 0
61 self.block_written = 0
62 self.block_stashed = 0
75 def ParseTransferList(self, name): argument
79 lines = self.package.read(name).strip().splitlines()
132 self.block_written += blocks_written
133 self.block_stashed += my_stash.blocks_stashed
143 def PrintDataInfo(self, partition): argument
145 new_data = self.package.getinfo(partition + ".new.dat")
146 patch_data = self.package.getinfo(partition + ".patch.dat")
160 self.new_data_size += new_data.file_size
161 self.patch_data_size += patch_data.file_size
163 def AnalyzePartition(self, partition): argument
165 assert partition + ".new.dat" in self.package.namelist()
166 assert partition + ".patch.dat" in self.package.namelist()
167 assert partition + ".transfer.list" in self.package.namelist()
169 self.PrintDataInfo(partition)
170 self.ParseTransferList(partition + ".transfer.list")
172 def PrintMetadata(self): argument
176 for line in self.package.read(metadata_path).strip().splitlines():
187 def Analyze(self): argument
188 logging.info("Analyzing ota package: " + self.package.filename)
189 self.PrintMetadata()
190 assert "system.new.dat" in self.package.namelist()
191 self.AnalyzePartition("system")
192 if "vendor.new.dat" in self.package.namelist():
193 self.AnalyzePartition("vendor")
200 OtaPackageParser.GetSizeString(self.new_data_size))
202 OtaPackageParser.GetSizeString(self.patch_data_size))
204 OtaPackageParser.GetSizeString(self.block_written * BLOCK_SIZE))
206 OtaPackageParser.GetSizeString(self.block_stashed * BLOCK_SIZE))