Convert a pronto code to a discrete (single button press) Kira code

def pronto2kira(data):
    """Convert a pronto code to a discrete (single button press) Kira code"""
    octets = [int(x, 16) for x in data.split()]
    preamble = octets[:4]
    convert = lambda x: 1000.0 / (x * 0.241246)
    freq = convert(preamble[1])
    period = 1000000.0 / (freq * 1000.0)
    dataLen = preamble[2]
    res = "K %02X%02X " %(freq, dataLen)
    res += " ".join(["%0.4X" % min(0x2000, (period * x)) for x in octets[4: 4+(2*dataLen)]])
    return res