Explorer
/proc/233/root/tmp/aa053-writer-inventory.py
← Zurück ↓ Download
from pathlib import Path
import re
roots=[Path('/opt/struktur/social-media-agent'),Path('/opt/struktur/social-media-radar')]
rx=re.compile(r'(?i)\b(INSERT\s+(?:OR\s+IGNORE\s+)?INTO|UPDATE|DELETE\s+FROM|CREATE\s+TABLE(?:\s+IF\s+NOT\s+EXISTS)?)\s+[\`\"]?([A-Za-z_][A-Za-z0-9_]*)')
route_rx=re.compile(r'@(app|bp|blueprint)\.(?:route|get|post|put|patch|delete)\([^\n]+')
for root in roots:
 print('ROOT',root)
 for p in sorted(root.rglob('*.py')):
  s=str(p)
  if any(x in s for x in ('/.venv/','/__pycache__/','/tests/')) or '.bak' in p.name: continue
  try:t=p.read_text(errors='replace')
  except OSError: continue
  hits=sorted(set(a.upper()+' '+b for a,b in rx.findall(t)))
  routes=route_rx.findall(t)
  route_lines=[line.strip() for line in t.splitlines() if '@app.route' in line or '@bp.route' in line]
  if hits or route_lines:
   print(str(p),'| SQL:',', '.join(hits)[:900],'| ROUTE_LINES:', '; '.join(route_lines)[:700])