def is_valid_disk(device):
 partitions = []
 for partline in open('/proc/partitions').readlines():
  fields = partline.strip().split()
  if ((len(fields) != 4) or partline.startswith('major')):
   continue
  (major, minor, blocks, partname) = fields
  blocks = int(blocks)
  if (not partname[(-1)].isdigit()):
   if (device.strip('/dev/') == partname):
    return True
 return False

def is_valid_disk ( device ) : partitions = [ ] for partline in open ( '/proc/partitions' ) . readlines ( ) : fields = partline . strip ( ) . split ( ) if ( ( len ( fields ) != 4 ) or partline . startswith ( 'major' ) ) : continue ( major , minor , blocks , partname ) = fields blocks = int ( blocks ) if ( not partname [ ( - 1 ) ] . isdigit ( ) ) : if ( device . strip ( '/dev/' ) == partname ) : return True return False
checks if a disk is valid .