diff --git a/legi/download.py b/legi/download.py index 8464c49..6f2d3cc 100644 --- a/legi/download.py +++ b/legi/download.py @@ -15,16 +15,17 @@ def download_legi(dst_dir): + if not os.path.exists(dst_dir): + os.mkdir(dst_dir) local_files = {filename: {} for filename in os.listdir(dst_dir)} ftph = ftplib.FTP() ftph.connect(DILA_FTP_HOST, DILA_FTP_PORT) ftph.login() ftph.cwd(DILA_LEGI_DIR) - remote_files = {filename: {} for filename in ftph.nlst() if 'legi_' in filename} - local_set = set(local_files.keys()) - remote_set = set(remote_files.keys()) - common_files = list(local_set & remote_set) - missing_files = list(remote_set - local_set) + remote_files = [filename for filename in ftph.nlst() if 'legi_' in filename] + common_files = [f for f in remote_files if f in local_files] + missing_files = [f for f in remote_files if f not in local_files] + remote_files = {filename: {} for filename in remote_files} for filename in common_files: local_files[filename]['size'] = os.path.getsize( os.path.join(dst_dir, filename)