Files
SirRoboGarage/tr_bots/_salvage/portaudit/methods.py
T
SirStone fcaa7ba183 tools/raw_recorder + tr_bots/_salvage: recorder source and the legacy port
tools/raw_recorder/RawRecord.java + shadow/GameRecorder.java  the observer
    that writes the .battle.gz corpora in data/ (gitignored, regenerable)
  tools/raw_recorder/query.py, sample_outline.md               query helpers
    and the shape of a capture
  tr_bots/_salvage/                                           the port audit:
    portaudit/{methods,static}.py, shim/, and the tr_wrappers/*.json + *.sh
    for 29 rescued legacy bots, with legacy_bots/MANIFEST.sha256
2026-10-05 22:43:41 +02:00

51 lines
1.8 KiB
Python

import re, os, sys
root = "/tmp/portaudit/src"
results = []
# regex for method decl: modifiers... returnType name(args) {
decl_re = re.compile(r'^\s*(?:public|private|protected|static|final|abstract|synchronized|native|\s)*[\w\[\]<>.,\s]+\s+(\w+)\s*\([^;{]*\)\s*\{')
for dirpath, _, files in os.walk(root):
for f in files:
if not f.endswith(".java"):
continue
path = os.path.join(dirpath, f)
with open(path) as fh:
lines = fh.readlines()
i = 0
while i < len(lines):
line = lines[i]
m = decl_re.match(line)
# skip control statements / class decls
if m and not re.match(r'^\s*(if|for|while|switch|catch|do|else|try|synchronized|return|new)\b', line):
name = m.group(1)
# find matching brace
depth = 0
started = False
j = i
end = None
while j < len(lines):
for ch in lines[j]:
if ch == '{':
depth += 1
started = True
elif ch == '}':
depth -= 1
if started and depth == 0:
end = j
break
if end is not None:
break
j += 1
if end is not None and 'class ' not in line and 'interface ' not in line:
size = end - i + 1
results.append((size, f"{path.replace(root+'/','')}:{i+1}", name))
i = end + 1 if end is not None else i + 1
else:
i += 1
results.sort(reverse=True)
for size, loc, name in results[:25]:
print(f"{size:5d} {loc:50s} {name}")