def get_most_complete_pm(pms):
    """ Return plugin match with longer version, if not available
        will return plugin match with ``presence=True``
    """
    if not pms:
        return None

    selected_version = None
    selected_presence = None

    for pm in pms:
        if pm.version:
            if not selected_version:
                selected_version = pm
            else:
                if len(pm.version) > len(selected_version.version):
                    selected_version = pm
        elif pm.presence:
            selected_presence = pm

    return selected_version or selected_presence
def get_most_complete_pm ( pms ) : if not pms : return None selected_version = None selected_presence = None for pm in pms : if pm . version : if not selected_version : selected_version = pm else : if len ( pm . version ) > len ( selected_version . version ) : selected_version = pm elif pm . presence : selected_presence = pm return selected_version or selected_presence
Return plugin match with longer version, if not available
        will return plugin match with ``presence=True``