def archive(self, filename, archive_path): """ Archive a copy of filename """ if not os.path.exists(archive_path): os.makedirs(archive_path) if os.path.exists(archive_path): name = os.path.basename(filename) if os.path.exists(archive_path + '/' + name): new_name = add_date_to_filename(name, False) shutil.copyfile(filename, archive_path + '/' + new_name) shutil.copy(filename, archive_path)
def archive(self, filename, archive_path): """ Archive a copy of filename """ archive_path2 = archive_path + '_previous' if not os.path.exists(archive_path): os.makedirs(archive_path) if not os.path.exists(archive_path2): os.makedirs(archive_path2) if os.path.exists(archive_path): name = os.path.basename(filename) archived_file = archive_path + '/' + name if os.path.exists(archived_file): new_name = add_date_to_filename(name, False) #shutil.copyfile(archived_file, archive_path2 + '/' + new_name) shutil.copy(filename, archive_path)