BmapCreate: fix and tidy-up bmap file formatting
authorArtem Bityutskiy <artem.bityutskiy@intel.com>
Tue, 21 Jan 2014 15:02:44 +0000 (17:02 +0200)
committerArtem Bityutskiy <artem.bityutskiy@intel.com>
Wed, 22 Jan 2014 07:22:40 +0000 (09:22 +0200)
We generated bogus commentary for files with zero mapped block:

<!-- Count of mapped blocks: 0 bytes or 0.0%0.0    -->
        <MappedBlocksCount> 0   </MappedBlocksCount>

and this patch fixes it. On top of this, we put too many white-spaces
in the <MappedBlocksCount> because we used wrong variable to calculate
the maximum amount of spaces. Fix this as well.

Change-Id: Icf80b1b8cdba7785755890f066824bb3abb42e0a
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
bmaptools/BmapCreate.py

index b70fd73de82462ff91b390f1c6860d5128fa4081..3df14461b4368948f7c9a5235883332b29ec3a55 100644 (file)
@@ -218,8 +218,6 @@ class BmapCreate(object):
         # We do not know the amount of mapped blocks at the moment, so just put
         # whitespaces instead of real numbers. Assume the longest possible
         # numbers.
-        mapped_count = ' ' * len(str(self.image_size))
-        mapped_size_human = ' ' * len(self.image_size_human)
 
         xml = _BMAP_START_TEMPLATE \
                % (SUPPORTED_BMAP_VERSION, self.image_size_human,
@@ -229,14 +227,14 @@ class BmapCreate(object):
         self._f_bmap.write(xml)
         self._mapped_count_pos1 = self._f_bmap.tell()
 
-        # Just put white-spaces instead of real information about mapped blocks
-        xml  = "%s or %.1f    -->\n" % (mapped_size_human, 100.0)
+        xml  = "%s or %s   -->\n" % (' ' * len(self.image_size_human),
+                                   ' ' * len("100.0%"))
         xml += "    <MappedBlocksCount> "
 
         self._f_bmap.write(xml)
         self._mapped_count_pos2 = self._f_bmap.tell()
 
-        xml  = "%s </MappedBlocksCount>\n\n" % mapped_count
+        xml  = "%s </MappedBlocksCount>\n\n" % (' ' * len(str(self.blocks_cnt)))
 
         # pylint: disable=C0301
         xml += "    <!-- Type of checksum used in this file -->\n"