Revision 88f83027 image_creator/gpt.py

b/image_creator/gpt.py
42 42
class MBR(object):
43 43
    """Represents a Master Boot Record."""
44 44
    class Partition(object):
45
        """Represents a partition entry in MBR"""
45 46
        format = "<B3sB3sLL"
46 47

  
47 48
        def __init__(self, raw_part):
49
            """Create a Partition instance"""
48 50
            (
49 51
                self.status,
50 52
                self.start,
......
55 57
            ) = struct.unpack(self.format, raw_part)
56 58

  
57 59
        def pack(self):
60
            """Pack the partition values into a binary string"""
58 61
            return struct.pack(self.format,
59 62
                               self.status,
60 63
                               self.start,
......
112 115
    510     2               MBR signature
113 116
    """
114 117
    def __init__(self, block):
118
        """Create an MBR instance"""
115 119
        raw_part = {}
116 120
        (self.code_area,
117 121
         raw_part[0],
......
126 130

  
127 131
    @staticmethod
128 132
    def size():
129
        """Returns the size of a Master Boot Record."""
133
        """Return the size of a Master Boot Record."""
130 134
        return struct.calcsize(MBR.format)
131 135

  
132 136
    def pack(self):
133
        """Packs an MBR to a binary string."""
137
        """Pack an MBR to a binary string."""
134 138
        return struct.pack(self.format,
135 139
                           self.code_area,
136 140
                           self.part[0].pack(),
......
174 178
        """
175 179

  
176 180
        def __init__(self, block):
181
            """Create a GPTHeader instance"""
177 182
            (self.signature,
178 183
             self.revision,
179 184
             self.hdr_size,
......
207 212

  
208 213
        @staticmethod
209 214
        def size():
210
            """Returns the size of a GPT Header."""
215
            """Return the size of a GPT Header."""
211 216
            return struct.calcsize(GPTPartitionTable.GPTHeader.format)
212 217

  
213 218
        def __str__(self):
219
            """Print a GPTHeader""" 
214 220
            return "Signature: %s\n" % self.signature + \
215 221
                   "Revision: %r\n" % self.revision + \
216 222
                   "Header Size: %d\n" % self.hdr_size + \
......
227 233
                   "CRC32 of partition array: %s\n" % self.part_crc32
228 234

  
229 235
    def __init__(self, disk):
236
        """Create a GPTPartitionTable instance"""
230 237
        self.disk = disk
231 238
        with open(disk, "rb") as d:
232 239
            # MBR (Logical block address 0)
......
249 256
            self.secondary = self.GPTHeader(raw_header)
250 257

  
251 258
    def size(self):
252
        """Returns the payload size of GPT partitioned device."""
259
        """Return the payload size of GPT partitioned device."""
253 260
        return (self.primary.backup_lba + 1) * BLOCKSIZE
254 261

  
255 262
    def shrink(self, size, old_size):

Also available in: Unified diff