From: Artem Bityutskiy Date: Tue, 6 Nov 2012 12:31:43 +0000 (+0200) Subject: BmapFlasher: separate sizes initialization to a function X-Git-Tag: v1.0~157 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a632b54c385d59118e683bae227c03a41c99799b;p=tools%2Fbmap-tools.git BmapFlasher: separate sizes initialization to a function We will need this function in the next patch, so this is just a preparation. Change-Id: If2d8c1474dce3255f92da8ae7287c6f86d8bc204 Signed-off-by: Artem Bityutskiy --- diff --git a/bmaptools/BmapFlasher.py b/bmaptools/BmapFlasher.py index fbcf468..12125b2 100644 --- a/bmaptools/BmapFlasher.py +++ b/bmaptools/BmapFlasher.py @@ -75,10 +75,24 @@ class BmapFlasher: This module supports all the bmap format versions up version 'supported_bmap_version'. """ + def _initialize_sizes(self, image_size): + """ This function is only used when the there is no bmap. It + initializes attributes like 'bmap_blocks_cnt', 'bmap_mapped_cnt', + etc. Normally, the values are read from the bmap file, but in this + case they are just set to something resonable. """ + + self.bmap_image_size = image_size + self.bmap_image_size_human = human_size(image_size) + self.bmap_blocks_cnt = self.bmap_image_size + self.bmap_block_size - 1 + self.bmap_blocks_cnt /= self.bmap_block_size + self.bmap_mapped_cnt = self.bmap_blocks_cnt + self.bmap_mapped_size = self.bmap_image_size + self.bmap_mapped_size_human = self.bmap_image_size_human + def _parse_bmap(self): """ This is an internal helper function which parses the bmap file and - initializes bmap-related variables like 'block_size', 'mapped_cnt', + initializes attributes 'bmap_block_size', 'bmap_mapped_cnt', etc. """ try: @@ -297,14 +311,7 @@ class BmapFlasher: image_size += len(chunk) - # Now we finally know the image size, initialize some of the - # user-visible variables - self.bmap_image_size = image_size - self.bmap_image_size_human = human_size(image_size) - self.bmap_blocks_cnt = self.bmap_image_size / self.bmap_block_size - self.bmap_mapped_cnt = self.bmap_blocks_cnt - self.bmap_mapped_size = self.bmap_image_size - self.bmap_mapped_size_human = self.bmap_image_size_human + self._initialize_sizes(image_size) if sync: self.sync()