Skip to content

Commit cad32b8

Browse files
committed
add python script put source code into text file
1 parent c60099c commit cad32b8

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
source_code.txt
2+
13
# Generated by Cargo
24
# will have compiled files and executables
35
debug/

get_source.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/python
2+
import os
3+
4+
def collect_rust_files(directory, output_file):
5+
with open(output_file, 'w') as outfile:
6+
for root, dirs, files in os.walk(directory):
7+
for file in files:
8+
if file.endswith('.rs'):
9+
file_path = os.path.join(root, file)
10+
outfile.write(f"---- {file_path} ----\n\n")
11+
with open(file_path, 'r') as infile:
12+
outfile.write(infile.read())
13+
outfile.write("\n\n")
14+
15+
if __name__ == "__main__":
16+
source_directory = "./src"
17+
output_file = "source_code.txt"
18+
19+
collect_rust_files(source_directory, output_file)
20+
print(f"source code collected in {output_file}")

0 commit comments

Comments
 (0)