def get_latest_release(ftp=None):
    """Use files on the Ensembl FTP server to determine the latest release.

    Parameters
    ----------
    ftp : ftplib.FTP, optional
        FTP connection (with logged in user "anonymous").

    Returns
    -------
    int
        The version number of the latest release.
    """
    if ftp is not None:
        assert isinstance(ftp, ftplib.FTP)

    close_connection = False
    if ftp is None:
        ftp_server = 'ftp.ensembl.org'
        user = 'anonymous'
        ftp = ftplib.FTP(ftp_server)
        ftp.login(user)
        close_connection = True

    data = []
    ftp.dir('pub', data.append)
    pat = re.compile(r'.* current_README -> release-(\d+)/README$')
    latest = []
    for d in data:
        m = pat.match(d)
        if m is not None:
            latest.append(int(m.group(1)))

    assert len(latest) == 1, len(latest)
    latest = latest[0]

    if close_connection:
        ftp.close()

    return latest
def get_latest_release ( ftp = None ) : if ftp is not None : assert isinstance ( ftp , ftplib . FTP ) close_connection = False if ftp is None : ftp_server = 'ftp.ensembl.org' user = 'anonymous' ftp = ftplib . FTP ( ftp_server ) ftp . login ( user ) close_connection = True data = [ ] ftp . dir ( 'pub' , data . append ) pat = re . compile ( r'.* current_README -> release-(\d+)/README$' ) latest = [ ] for d in data : m = pat . match ( d ) if m is not None : latest . append ( int ( m . group ( 1 ) ) ) assert len ( latest ) == 1 , len ( latest ) latest = latest [ 0 ] if close_connection : ftp . close ( ) return latest
Use files on the Ensembl FTP server to determine the latest release.

    Parameters
    ----------
    ftp : ftplib.FTP, optional
        FTP connection (with logged in user "anonymous").

    Returns
    -------
    int
        The version number of the latest release.