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
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
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}")
|
||||
@@ -0,0 +1,20 @@
|
||||
import re, os
|
||||
root="/tmp/portaudit/src"
|
||||
pat=re.compile(r'^\s*(public|private|protected)?\s*static\s+(?!final)([\w\[\]<>,\.]+)\s+([A-Za-z_]\w*)\b.*;\s*$')
|
||||
counts={}
|
||||
allrows=[]
|
||||
for dp,_,fs in os.walk(root):
|
||||
for f in fs:
|
||||
if not f.endswith(".java"): continue
|
||||
p=os.path.join(dp,f)
|
||||
# note: static block 'static {' not matched
|
||||
for i,l in enumerate(open(p),1):
|
||||
s=l.strip()
|
||||
if s.startswith("//") or s.startswith("*"): continue
|
||||
m=pat.match(l)
|
||||
if m and "(" not in l.split(";")[0]:
|
||||
typ=m.group(2); name=m.group(3)
|
||||
allrows.append((p.replace(root+"/",""),i,typ,name))
|
||||
print("TOTAL static non-final fields:", len(allrows))
|
||||
for r in allrows:
|
||||
print(f" {r[0]}:{r[1]} {r[2]} {r[3]}")
|
||||
Reference in New Issue
Block a user