def version_to_string(version, parts=3):
    """ Convert an n-part version number encoded as a hexadecimal value to a
    string.  version is the version number.  Returns the string.
    """
    part_list = [str(version >> 16 & 255)]
    if parts > 1:
        part_list.append(str(version >> 8 & 255))
        if parts > 2:
            part_list.append(str(version & 255))
    return '.'.join(part_list)
