If token-savior didn't run, derive a symbol-ish sample from .py basenames.
(root: Path)
| 371 | |
| 372 | |
| 373 | def fallback_sample(root: Path) -> list[str]: |
| 374 | """If token-savior didn't run, derive a symbol-ish sample from .py basenames.""" |
| 375 | cands: list[str] = [] |
| 376 | for dirpath, _, files in os.walk(root): |
| 377 | for f in files: |
| 378 | if f.endswith(".py") and not f.startswith("_"): |
| 379 | cands.append(f[:-3]) |
| 380 | if not cands: |
| 381 | return [] |
| 382 | rng = random.Random(RANDOM_SEED) |
| 383 | return rng.sample(cands, min(NUM_QUERY_SAMPLES, len(cands))) |
| 384 | |
| 385 | |
| 386 | # --------------------------------------------------------------------------- |