| 1234567891011121314151617181920 |
- import re
- from pathlib import Path
- ROOT = Path(r"F:/shop/java-rewrite/yoshop-java/src/main/java/cn/yoshop/store/controller")
- for p in sorted(ROOT.glob("*.java")):
- lines = p.read_text(encoding="utf-8").split("\n")
- idx = [i for i, l in enumerate(lines) if l.startswith("import cn.yoshop.")]
- if not idx:
- continue
- start, end = idx[0], idx[-1]
- block = lines[start:end + 1]
- if any(not b.startswith("import cn.yoshop.") for b in block):
- print(f"SKIP {p.name}: 非连续块")
- continue
- ordered = sorted(block)
- if ordered != block:
- lines[start:end + 1] = ordered
- p.write_text("\n".join(lines), encoding="utf-8")
- print(f"OK {p.name}")
|