Explorer
/proc/2012/task/2095/root/tmp/aa053_scanwriters.py
← Zurück ↓ Download
import os
import re

ROOTS = ["/opt/struktur/social-media-agent", "/opt/struktur/social-media-radar"]
SKIP_DIRS = {".git", ".venv", "__pycache__", "generated_visuals", "generated_packages", "logs", "reports", "node_modules"}
WRITE = re.compile(r"\b(INSERT\s+INTO|UPDATE|DELETE\s+FROM|REPLACE\s+INTO|ALTER\s+TABLE|CREATE\s+TABLE|DROP\s+TABLE)\b", re.I)
EXEC = re.compile(r"\.execute(?:many)?\s*\(")
for root in ROOTS:
    print(f"ROOT {root}")
    for dp, dns, fns in os.walk(root):
        dns[:] = [d for d in dns if d not in SKIP_DIRS]
        for fn in sorted(fns):
            if not fn.endswith(".py"):
                continue
            path = os.path.join(dp, fn)
            try:
                lines = open(path, encoding="utf-8", errors="ignore").read().splitlines()
            except OSError:
                continue
            hits = []
            for no, line in enumerate(lines, 1):
                if WRITE.search(line):
                    hits.append((no, line.strip()))
            if hits:
                print(f"FILE {path} writes={len(hits)}")
                for no, line in hits:
                    print(f"  {no}: {line[:240]}")