def __init__(self, bytes): self.image_type = "T64 Tape Container" self.bytes = bytes self._validate() self.directory_size, self.raw_label =\ struct.unpack(TAPE_HEADER, bytes[0x20:0x40]) self.label = self.raw_label.strip() self.entries = [ TapeEntry(x) for x in blocks(self.bytes, 0x20, offset=0x40, max=self.directory_size) ]
def __init__(self, bytes): self.image_type = "T64 Tape Container" self.bytes = bytes self._validate() self.directory_size, self.raw_label =\ struct.unpack(TAPE_HEADER, bytes[0x20:0x40]) self.label = self.raw_label.strip() self.entries = [ TapeEntry(x) for x in blocks( self.bytes, 0x20, offset=0x40, max=self.directory_size) ]
def test_blocks(self): b = list(blocks('abcdefgh', 2)) self.assertEquals(4, len(b))
def test_max_offset(self): b = list(blocks('abcdefgh', 3, max=2, offset=2)) self.assertEquals(2, len(b))
def test_offset(self): b = list(blocks('abcdefgh', 2, offset=2)) self.assertEquals(3, len(b))
def test_max(self): b = list(blocks('abcdefgh', 2, max=2)) self.assertEquals(2, len(b))
def __init__(self, bytes, track, sector): """Initialize this DirectorySector from a disk sector.""" self.bytes = bytes self.location = (track, sector) self.next_sector = (bytes[0], bytes[1]) self.entries = [DirectoryEntry(x) for x in blocks(bytes, 32)]