def determine_disk_image_type(image_meta):
    if not image_meta.obj_attr_is_set("disk_format"):
        return None

    disk_format_map = {
        'ami': ImageType.DISK,
        'aki': ImageType.KERNEL,
        'ari': ImageType.RAMDISK,
        'raw': ImageType.DISK_RAW,
        'vhd': ImageType.DISK_VHD,
        'iso': ImageType.DISK_ISO,
    }

    try:
        image_type = disk_format_map[image_meta.disk_format]
    except KeyError:
        raise exception.InvalidDiskFormat(disk_format=image_meta.disk_format)

    LOG.debug("Detected %(type)s format for image %(image)s",
              {'type': ImageType.to_string(image_type),
               'image': image_meta})

    return image_type
>>> # these first two could certainly be replaced
dataset/ETHPy150Open BU-NU-CLOUD-SP16/Trusted-Platform-Module-nova/nova/virt/xenapi/vm_utils.py/determine_disk_image_type--crossover with--dataset/ETHPy150Open dimagi/commcare-hq/corehq/apps/receiverwrapper/util.py/get_version_from_appversion_text