-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontext_gen.py
More file actions
120 lines (104 loc) · 2.66 KB
/
context_gen.py
File metadata and controls
120 lines (104 loc) · 2.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
import os
IGNORE_DIRS = {
".git",
"__pycache__",
".venv",
"venv",
"env",
".idea",
".vscode",
".cursor",
"node_modules",
"vendor",
"cache",
"logs",
".pytest_cache",
".mypy_cache",
".ruff_cache",
".tox",
"dist",
"build",
"htmlcov",
".hypothesis",
}
IGNORE_DIR_PATTERNS = [
".egg-info",
]
INCLUDE_EXT = {
".py",
".md",
".sql",
".txt",
".yml",
".yaml",
".json",
".toml",
".ini",
".cfg",
".conf",
}
IGNORE_FILES = {
"composer.lock",
"package-lock.json",
"yarn.lock",
"poetry.lock",
".gitignore",
".gitattributes",
".env",
".env.example",
".DS_Store",
"Thumbs.db",
".coverage",
"coverage.xml",
".pytest_cache",
"full_project_context_testizer.txt",
}
IGNORE_EXTENSIONS = {
".pyc",
".pyo",
".pyd",
".log",
".cache",
}
def generate_context():
output_file = "full_project_context_testizer.txt"
with open(output_file, "w", encoding="utf-8") as outfile:
outfile.write("=" * 80 + "\n")
outfile.write("TESTIZER EMAIL FUNNELS - FULL PROJECT CONTEXT\n")
outfile.write("=" * 80 + "\n\n")
for root, dirs, files in os.walk("."):
dirs[:] = [
d
for d in dirs
if d not in IGNORE_DIRS
and not any(pattern in d for pattern in IGNORE_DIR_PATTERNS)
]
for file in files:
if file in IGNORE_FILES:
continue
_, ext = os.path.splitext(file)
if ext in IGNORE_EXTENSIONS:
continue
if ext in INCLUDE_EXT or file in (
"Dockerfile",
".htaccess",
"requirements.txt",
):
path = os.path.join(root, file)
path = os.path.normpath(path)
outfile.write(f"\n{'='*80}\n")
outfile.write(f"FILE: {path}\n")
outfile.write(f"{'='*80}\n\n")
try:
with open(
path, "r", encoding="utf-8", errors="ignore"
) as infile:
content = infile.read()
outfile.write(content)
if not content.endswith("\n"):
outfile.write("\n")
except Exception as e:
outfile.write(f"Error reading file: {e}\n")
print(f"Ready. File {output_file} created.")
if __name__ == "__main__":
generate_context()