From: Artem Bityutskiy Date: Fri, 1 Nov 2013 10:38:58 +0000 (+0200) Subject: BmapCopy: verify versions in a single function X-Git-Tag: v3.1~24 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7592bd4fc3a0842629b6721cb6760f21403eedf0;p=tools%2Fbmap-tools.git BmapCopy: verify versions in a single function 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 --- 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())