summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtem Bityutskiy <artem.bityutskiy@intel.com>2013-04-11 09:04:28 +0300
committerArtem Bityutskiy <artem.bityutskiy@intel.com>2013-04-19 16:25:55 +0300
commitc7329ed7abb7754182c6fcd75ff81e73f61dc90d (patch)
treebc51d5866621e648021e804fc43f376c7a552594
parent39a18410920986e625551158e708ce9a304c4943 (diff)
downloadmic-c7329ed7abb7754182c6fcd75ff81e73f61dc90d.tar.gz
mic-c7329ed7abb7754182c6fcd75ff81e73f61dc90d.tar.bz2
mic-c7329ed7abb7754182c6fcd75ff81e73f61dc90d.zip
gpt_parser: harmonize naming a bit
Use 'raw_hdr' for raw header and 'header' for the header dictionary. This makes the code easier to read because you always know what you deal with from the variable name. Change-Id: Iae0420ec149861067a455bb62276cb50fc6ba719 Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
-rw-r--r--mic/utils/gpt_parser.py48
1 files changed, 24 insertions, 24 deletions
diff --git a/mic/utils/gpt_parser.py b/mic/utils/gpt_parser.py
index 52e1a6c..02bf24f 100644
--- a/mic/utils/gpt_parser.py
+++ b/mic/utils/gpt_parser.py
@@ -116,39 +116,39 @@ class GptParser:
# Read and validate the primary GPT header
self.disk_obj.seek(self.sector_size)
try:
- header = self.disk_obj.read(struct.calcsize(_GPT_HEADER_FORMAT))
+ raw_hdr = self.disk_obj.read(struct.calcsize(_GPT_HEADER_FORMAT))
except IOError as err:
raise MountError("cannot read from file '%s': %s" % \
(self.disk_path, err))
- header = struct.unpack(_GPT_HEADER_FORMAT, header)
- _validate_header(header)
+ raw_hdr = struct.unpack(_GPT_HEADER_FORMAT, raw_hdr)
+ _validate_header(raw_hdr)
if not primary:
# Read and validate the backup GPT header
- self.disk_obj.seek(header[6] * self.sector_size)
+ self.disk_obj.seek(raw_hdr[6] * self.sector_size)
try:
- header = self.disk_obj.read(struct.calcsize(_GPT_HEADER_FORMAT))
+ raw_hdr = self.disk_obj.read(struct.calcsize(_GPT_HEADER_FORMAT))
except IOError as err:
raise MountError("cannot read from file '%s': %s" % \
(self.disk_path, err))
- header = struct.unpack(_GPT_HEADER_FORMAT, header)
- _validate_header(header)
-
- return (header[0], # 0. Signature
- header[1], # 1. Revision
- header[2], # 2. Header size in bytes
- header[3], # 3. Header CRC32
- header[5], # 4. Current LBA
- header[6], # 5. Backup LBA
- header[7], # 6. First usable LBA for partitions
- header[8], # 7. Last usable LBA
- _stringify_uuid(header[9]), # 8. Disk GUID
- header[10], # 9. Starting LBA of array of partition entries
- header[11], # 10. Number of partition entries
- header[12], # 11. Size of a single partition entry
- header[13]) # 12. CRC32 of partition array
+ raw_hdr = struct.unpack(_GPT_HEADER_FORMAT, raw_hdr)
+ _validate_header(raw_hdr)
+
+ return (raw_hdr[0], # 0. Signature
+ raw_hdr[1], # 1. Revision
+ raw_hdr[2], # 2. Header size in bytes
+ raw_hdr[3], # 3. Header CRC32
+ raw_hdr[5], # 4. Current LBA
+ raw_hdr[6], # 5. Backup LBA
+ raw_hdr[7], # 6. First usable LBA for partitions
+ raw_hdr[8], # 7. Last usable LBA
+ _stringify_uuid(raw_hdr[9]), # 8. Disk GUID
+ raw_hdr[10], # 9. Starting LBA of array of partition entries
+ raw_hdr[11], # 10. Number of partition entries
+ raw_hdr[12], # 11. Size of a single partition entry
+ raw_hdr[13]) # 12. CRC32 of partition array
def get_partitions(self):
""" This is a generator which parses teh GPT partition table and
@@ -160,9 +160,9 @@ class GptParser:
This tuple corresponds to the GPT partition record format. Please, see the
UEFI standard for the description of these fields. """
- gpt_header = self.read_header()
- entries_start = gpt_header[9] * self.sector_size
- entries_count = gpt_header[10]
+ header = self.read_header()
+ entries_start = header[9] * self.sector_size
+ entries_count = header[10]
self.disk_obj.seek(entries_start)