[bmap-tools] [PATCH 02/16] BmapCopy: verify versions in a single function
Artem Bityutskiy
dedekind1 at gmail.com
Mon Nov 4 03:05:22 EST 2013
From: Artem Bityutskiy <artem.bityutskiy at intel.com>
This patch is a minor clean-up and a preparation to the upcoming changes. It
makes sure that all the differences between various bmap format version are
handled in the '_parse_bmap()' method, and we do not have to worry about the
format differences later on.
Change-Id: I00b0cc7b5f9c3372f85fb7519c3ce768f5db3bf4
Signed-off-by: Artem Bityutskiy <artem.bityutskiy at intel.com>
---
bmaptools/BmapCopy.py | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/bmaptools/BmapCopy.py b/bmaptools/BmapCopy.py
index fe8897c..357b45d 100644
--- a/bmaptools/BmapCopy.py
+++ b/bmaptools/BmapCopy.py
@@ -176,6 +176,7 @@ class BmapCopy:
self._cs_type = None
self._cs_len = None
self._cs_attrib_name = None
+ self._bmap_cs_attrib_name = None
# Special quirk for /dev/null which does not support fsync()
if stat.S_ISCHR(st_data.st_mode) and \
@@ -247,10 +248,7 @@ class BmapCopy:
import mmap
- if self.bmap_version_minor == 3:
- correct_chksum = self._xml.find("BmapFileSHA1").text.strip()
- else:
- correct_chksum = self._xml.find("BmapFileChecksum").text.strip()
+ correct_chksum = self._xml.find(self._bmap_cs_attrib_name).text.strip()
# Before verifying the shecksum, we have to substitute the checksum
# value stored in the file with all zeroes. For these purposes we
@@ -329,9 +327,11 @@ class BmapCopy:
if self.bmap_version_minor == 3:
self._cs_type = "sha1"
self._cs_attrib_name = "sha1"
+ self._bmap_cs_attrib_name = "BmapFileSHA1"
else:
self._cs_type = xml.find("ChecksumType").text.strip()
self._cs_attrib_name = "chksum"
+ self._bmap_cs_attrib_name = "BmapFileChecksum"
try:
self._cs_len = len(hashlib.new(self._cs_type).hexdigest())
--
1.8.1.4
More information about the Bmap-tools
mailing list