wolfhece.ftp.downloader

Module Contents

wolfhece.ftp.downloader._is_ftp_dir(ftp_handle, name, guess_by_extension=True)[source]

simply determines if an item listed on the ftp server is a valid directory or not

wolfhece.ftp.downloader._make_parent_dir(fpath)[source]

ensures the parent directory of a filepath exists

wolfhece.ftp.downloader._download_ftp_file(ftp_handle, name, dest, overwrite)[source]

downloads a single file from an ftp server

wolfhece.ftp.downloader._file_name_match_patern(pattern, name)[source]

returns True if filename matches the pattern

wolfhece.ftp.downloader._mirror_ftp_dir(ftp_handle, name, overwrite, guess_by_extension, pattern)[source]

replicates a directory on an ftp server recursively

wolfhece.ftp.downloader.download_ftp_tree(ftp_handle, path, destination, pattern=None, overwrite=False, guess_by_extension=True)[source]

Downloads an entire directory tree from an ftp server to the local destination

Parameters:
  • ftp_handle – an authenticated ftplib.FTP instance

  • path – the folder on the ftp server to download

  • destination – the local directory to store the copied folder

  • pattern – Python regex pattern, only files that match this pattern will be downloaded.

  • overwrite – set to True to force re-download of all files, even if they appear to exist already

  • guess_by_extension – It takes a while to explicitly check if every item is a directory or a file.

If this flag is set to True, it will assume any file ending with a three character extension “.???” is a file and not a directory. Set to False if some folders may have a “.” in their names -4th position.

wolfhece.ftp.downloader.mysite = 'some_ftp_site'[source]