#!/usr/bin/env python


def get_disk_attributes():
    """Search for PTTYPE and TYPE attributes of the disk
    Returns a dictionary.
    """
    pass


def get_partition_types():
    """Search for partitions and get their types.
    Returns set of types.
    """
    pass

#############################################


possible_layouts = set()
contradictory_scenarios = set('whole_disk_filesystem', 'partition_table_present')


# Two contradictory disk attributes
contradictory_attributes = set('PTTYPE', 'TYPE')


# Filesystems, that may have embedded partitions [disk_filesystem: [partition_filesystems]]
fs_exceptions = {'iso9660': [], 'zfs_member': ['zfs_member']} # empty list means 'any type allowed'


################## Get information ###########################

# Get disk attributes ('blkid /dev/sda')
disk_attributes = get_disk_attributes()

# Search for partitions and get their types ('blkid | fgrep /dev/sda')
types_of_partitions = get_partition_types()


############# CHECK FOR DISCREPANCIES AND SURMISE POSSIBLE SCENARIOS #################

# Check if there are contradictory attributes in disk info

# If partition table present
if('PTTYPE' in disk_attributes):
    possible_layouts.add('partition_table_present')
# If whole disk filesystem
if('TYPE' in disk_attributes):
    possible_layouts.add('whole_disk_filesystem')
    disk_fs = disk_attributes['TYPE']
    # If partitions found, check if their types are allowed
    if(len(types_of_partitions) > 0):
        if( disk_fs in fs_exceptions):
            allowed_partition_types = fs_exceptions[disk_fs]
            if(allowed_partition_types > 0):
                for(ptype in types_of_partitions):
                    if(ptype not in allowed_partition_types):
                        # Discrepancy detected: maybe there should be a partition table
                        possible_layouts.add('partition_table_present')
                        break    
    
    

###########################

if(len(possible_layouts) > 1 ):
    # Two mutually exlusive variants detected!
    # Search for partitions and warn the user. Let him chose the right variant and suggest to erase the unwated signatures
   
    print("We detected discrepancies and see two possible mutually exlusive variants. If one of them is right, choose it.")
    # If one of the vatians has been chosen, suggest to delete all irrelevant signatures
    print("If you're sure you have chosen the right variant, let us delete all traces of the other.")






