# Path: rfid/formats/mifare/Mifare.py
# class MifareSector:
#     def __init__(self, blocks=None):
#         self.key_a = None
#         self.key_b = None
#         self.permission = None
#         self.extrabit = None
#         self.blocks = blocks
# 
#     def block(self, index):
#         return self.blocks[index]
#         
#     def __repr__(self):
#         return "Mifare Sector with %d blocks" % len(self.blocks)


from rfid.formats.mifare.Mifare import MifareSector

    def __repr__(self):
        return "Mifare Classic 4k card with UID: %s" % self.UID

    def blocks(self):
        for i in range(0, self._num_blocks):
            yield self.block(i)
            
    def sectors(self):
        for i in range(0, self._num_sectors):
            yield self.sector(i)
            
    def block(self, index):
        return self._carddata[index*16:(index+1)*16]
        
    def sector(self, index):
        if index < 32:
            width = 4
            index = index * width
        else:
            width = 16
            index = 32 * 4 + width * (index-32)
        
        data_blocks = []
        
        for i in range(index, index + width - 1):
            data_blocks.append(self.block(i))
            
        trailing_block = self.block(index + width -1)
        

# Path: rfid/formats/mifare/Mifare.py
# class MifareSector:
#     def __init__(self, blocks=None):
#         self.key_a = None
#         self.key_b = None
#         self.permission = None
#         self.extrabit = None
#         self.blocks = blocks
# 
#     def block(self, index):
#         return self.blocks[index]
#         
#     def __repr__(self):
#         return "Mifare Sector with %d blocks" % len(self.blocks)


# Path: rfid/formats/mifare/MifareClassic4k.py
from rfid.formats.mifare.Mifare import MifareSector


    def __repr__(self):
        return "Mifare Classic 4k card with UID: %s" % self.UID

    def blocks(self):
        for i in range(0, self._num_blocks):
            yield self.block(i)
            
    def sectors(self):
        for i in range(0, self._num_sectors):
            yield self.sector(i)
            
    def block(self, index):
        return self._carddata[index*16:(index+1)*16]
        
    def sector(self, index):
        if index < 32:
            width = 4
            index = index * width
        else:
            width = 16
            index = 32 * 4 + width * (index-32)
        
        data_blocks = []
        
        for i in range(index, index + width - 1):
            data_blocks.append(self.block(i))
            
        trailing_block = self.block(index + width -1)
        

        sector = MifareSector(data_blocks)