| 143 | |
| 144 | |
| 145 | def store_response_files(target_folder, response_files, existing_files): |
| 146 | for file_name in response_files: |
| 147 | full_file_name = os.path.join(target_folder, file_name) |
| 148 | |
| 149 | if response_files[file_name] is None: |
| 150 | # None content indicates that the file should be deleted. |
| 151 | if os.path.exists(full_file_name): |
| 152 | os.remove(full_file_name) |
| 153 | existing_files.remove(file_name) |
| 154 | else: |
| 155 | console.debug(f"WARNING! Cannot delete file! File {full_file_name} does not exist.") |
| 156 | |
| 157 | continue |
| 158 | |
| 159 | os.makedirs(os.path.dirname(full_file_name), exist_ok=True) |
| 160 | |
| 161 | with open(full_file_name, "w", encoding="utf-8") as f: |
| 162 | f.write(response_files[file_name]) |
| 163 | |
| 164 | if file_name not in existing_files: |
| 165 | existing_files.append(file_name) |
| 166 | |
| 167 | return existing_files |
| 168 | |
| 169 | |
| 170 | def open_from(dirs, file_name): |