From d7a5e8787d420da52fcf2dac68b3aba8c4d6b313 Mon Sep 17 00:00:00 2001 From: Alexander-D-Karpov Date: Mon, 4 Dec 2023 10:30:25 +0300 Subject: [PATCH] updated extract_folder --- extract_folder.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/extract_folder.py b/extract_folder.py index dbf32a8..6cc31d8 100644 --- a/extract_folder.py +++ b/extract_folder.py @@ -31,10 +31,16 @@ def structure_directory_content(input_dir, output_file=None, extensions=None): file.endswith(f".{ext}") for ext in extensions ): file_path = os.path.join(root, file) - outfile.write(f"# {os.path.relpath(file_path, input_dir)}\n") - with open(file_path, "r") as infile: - outfile.write(infile.read()) - outfile.write("\n\n") + try: + with open(file_path, "r") as infile: + data = infile.read() + outfile.write( + f"# {os.path.relpath(file_path, input_dir)}\n" + ) + outfile.write(data) + outfile.write("\n\n") + except UnicodeDecodeError: + continue if __name__ == "__main__":