def METHOD_NAME(ptype, subtype, partition_table_file, bin_file):  # type: (str, str, io.IOBase, IO) -> None
    table, _ = PartitionTable.from_file(partition_table_file)
    ptype_str = str(ptype)
    ptype = get_ptype_as_int(ptype)
    partitions = [p for p in table if p.type == ptype]
    if subtype is not None:
        ptype_str += ' ({})'.format(subtype)
        subtype = get_subtype_as_int(ptype, subtype)
        partitions = [p for p in partitions if p.subtype == subtype]
    if len(partitions) == 0:
        print('WARNING: Partition table does not contain any partitions matching {}'.format(ptype_str))
        return
    bin_name = os.path.basename(bin_file.name)
    bin_size = _file_size(bin_file)
    smallest_size = min(p.size for p in partitions)
    if smallest_size >= bin_size:
        free_size = smallest_size - bin_size
        free_size_relative = free_size / smallest_size
        print('{} binary size {:#x} bytes. Smallest {} partition is {:#x} bytes. {:#x} bytes ({:.0%}) free.'.format(
            bin_name, bin_size, ptype_str, smallest_size, free_size, free_size_relative))
        free_size_relative_critical = 0.05
        if free_size_relative < free_size_relative_critical:
            print('Warning: The smallest {} partition is nearly full ({:.0%} free space left)!'.format(ptype_str, free_size_relative))
        return
    too_small_partitions = [p for p in partitions if p.size < bin_size]
    if len(partitions) == 1:
        msg = '{} partition is'.format(ptype_str)
    elif len(partitions) == len(too_small_partitions):
        msg = 'All {} partitions are'.format(ptype_str)
    else:
        msg = '{}/{} {} partitions are'.format(len(too_small_partitions), len(partitions), ptype_str)
    msg += ' too small for binary {} size {:#x}:'.format(bin_name, bin_size)
    for p in too_small_partitions:
        msg += '\n  - {} (overflow {:#x})'.format(p, bin_size - p.size)
    if not allow_failures and len(partitions) == len(too_small_partitions):
        # if some partitions can fit the binary then just print a warning
        raise SystemExit('Error: ' + msg)
    else:
        print('Warning: ' + msg)