mirror of
https://github.com/Alexander-D-Karpov/scripts.git
synced 2024-11-25 13:03:44 +03:00
updated extract_folder
This commit is contained in:
parent
c294261a04
commit
d7a5e8787d
|
@ -31,10 +31,16 @@ def structure_directory_content(input_dir, output_file=None, extensions=None):
|
||||||
file.endswith(f".{ext}") for ext in extensions
|
file.endswith(f".{ext}") for ext in extensions
|
||||||
):
|
):
|
||||||
file_path = os.path.join(root, file)
|
file_path = os.path.join(root, file)
|
||||||
outfile.write(f"# {os.path.relpath(file_path, input_dir)}\n")
|
try:
|
||||||
with open(file_path, "r") as infile:
|
with open(file_path, "r") as infile:
|
||||||
outfile.write(infile.read())
|
data = infile.read()
|
||||||
|
outfile.write(
|
||||||
|
f"# {os.path.relpath(file_path, input_dir)}\n"
|
||||||
|
)
|
||||||
|
outfile.write(data)
|
||||||
outfile.write("\n\n")
|
outfile.write("\n\n")
|
||||||
|
except UnicodeDecodeError:
|
||||||
|
continue
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
Loading…
Reference in New Issue
Block a user