mirror of
https://github.com/hpd840321/starRiverProperty.git
synced 2026-06-10 00:40:30 +08:00
27c3949045
- .gitignore:显式放行全部 maven-*、scripts、dev-support、frontend、反1、artifacts、历史导出目录
- 新增跟踪:device-manager/device-sdk/legacy-public、davinci-manager、cwos-*、cwos-resource 等源码与附属资源
- davinci FileStorageManagerImpl:Feign Response 关闭、绝对 URL 拉流 SSRF 校验(协议/主机/解析地址)
- davinci OuterCallFeignClient:补充契约说明
- cwos-common-aks AksConstant:final 类 + 私有构造防误实例化
- device-manager DeviceConstant:沿用 DEFAULT_APPLICATIONID 拼写修正
Made-with: Cursor
Former-commit-id: 0a34c76a82
96 lines
2.9 KiB
Python
96 lines
2.9 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Remove JD-Core decompiler noise from Java sources under maven-*:
|
|
|
|
- Line prefix comments: /* */ and /* N */ (line numbers)
|
|
- Trailing metadata block: /* Location: ... JD-Core Version: ... */
|
|
|
|
Does not strip normal Javadoc /** ... */ or arbitrary block comments.
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
import re
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
RE_LINE_EMPTY_PREFIX = re.compile(r"^/\* +\*/\s*")
|
|
RE_LINE_NUM_PREFIX = re.compile(r"^/\* \d+ \*/\s*")
|
|
# Ends with line like " */" (space + */) after "* JD-Core Version: ..."
|
|
RE_TAIL_META = re.compile(
|
|
r"(?:^|\n)/\* Location:.*?\n\s*\*/\s*",
|
|
re.DOTALL,
|
|
)
|
|
|
|
|
|
def strip_content(text: str) -> str:
|
|
text = text.replace("\r\n", "\n").replace("\r", "\n")
|
|
lines = text.split("\n")
|
|
stripped = []
|
|
for line in lines:
|
|
line = RE_LINE_EMPTY_PREFIX.sub("", line)
|
|
line = RE_LINE_NUM_PREFIX.sub("", line)
|
|
stripped.append(line)
|
|
joined = "\n".join(stripped)
|
|
joined = RE_TAIL_META.sub("\n", joined)
|
|
if joined and not joined.endswith("\n"):
|
|
joined += "\n"
|
|
return joined
|
|
|
|
|
|
def process_file(path: Path, dry_run: bool) -> bool:
|
|
raw = path.read_text(encoding="utf-8", errors="replace")
|
|
new = strip_content(raw)
|
|
raw_norm = raw.replace("\r\n", "\n").replace("\r", "\n")
|
|
if raw_norm and not raw_norm.endswith("\n"):
|
|
raw_norm += "\n"
|
|
if new == raw_norm:
|
|
return False
|
|
if not dry_run:
|
|
path.write_text(new, encoding="utf-8", newline="\n")
|
|
return True
|
|
|
|
|
|
def main() -> int:
|
|
ap = argparse.ArgumentParser(description=__doc__)
|
|
ap.add_argument(
|
|
"roots",
|
|
nargs="*",
|
|
type=Path,
|
|
help="Optional roots (default: all maven-* under repo root next to scripts/)",
|
|
)
|
|
ap.add_argument("--dry-run", action="store_true", help="Report only, do not write")
|
|
args = ap.parse_args()
|
|
|
|
script_dir = Path(__file__).resolve().parent
|
|
repo = script_dir.parent
|
|
|
|
if args.roots:
|
|
roots = [Path(p).resolve() for p in args.roots]
|
|
else:
|
|
roots = sorted(repo.glob("maven-*"))
|
|
roots = [p for p in roots if p.is_dir()]
|
|
|
|
changed = 0
|
|
scanned = 0
|
|
for root in roots:
|
|
if not root.exists():
|
|
print(f"skip missing: {root}", file=sys.stderr)
|
|
continue
|
|
for path in root.rglob("*.java"):
|
|
if "/target/" in str(path).replace("\\", "/"):
|
|
continue
|
|
scanned += 1
|
|
if process_file(path, args.dry_run):
|
|
changed += 1
|
|
if args.dry_run:
|
|
print(f"would update: {path}")
|
|
|
|
print(f"Scanned: {scanned} Java files under {len(roots)} root(s)")
|
|
print(f"{'Would change' if args.dry_run else 'Changed'}: {changed} file(s)")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|