diff --git a/.gitignore b/.gitignore index fb94ebf..9b2352f 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -testdata/ \ No newline at end of file +testdata/ +output/ \ No newline at end of file diff --git a/anonymize_entries.py b/anonymize_entries.py index af91628..64c11e3 100644 --- a/anonymize_entries.py +++ b/anonymize_entries.py @@ -244,7 +244,7 @@ def extract_entries_to_temporary_folder( copy_dir(zip_fs, zip_path, temp_fs, canonical_filename) return canonical_filename - temp_fs = TempFS(identifier="dimocracy-voucher_anonymized", auto_clean=False) + temp_fs = TempFS(identifier="dimocracy-voucher_anonymized") for row in csv_contents: if row[KnownColumns.IgnoreResubmittedFile]: @@ -376,12 +376,18 @@ def anonymize_entries( ) -def zip_anonymized_entries( +def save_anonymized_files( args: AnonymizeEntriesArgs, csv_contents: CsvContents, temp_fs: TempFS, ): - print("STUB - zip_anonymized_entries") + if args.dry_run: + print("Dry run - not saving anonymized files") + return + timestamp = datetime.now().strftime("%Y%m%d-%H%M%S") + output_path = f"./output/anonymized-{timestamp}" + shutil.copytree(temp_fs.root_path, output_path) + print(f"Saved to {os.path.abspath(output_path)}") ############### @@ -404,7 +410,7 @@ def main(argv: list[str]): temp_fs = extract_entries_to_temporary_folder(args, csv_contents, dynamic_columns) anonymize_entries(args, csv_contents, temp_fs) - zip_anonymized_entries(args, csv_contents, temp_fs) + save_anonymized_files(args, csv_contents, temp_fs) if __name__ == "__main__":