48 lines
1.1 KiB
Python
48 lines
1.1 KiB
Python
#!/usr/bin/env python3
|
|
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
from pathlib import Path
|
|
|
|
|
|
def remove_icon_png_base64_lines(path: Path) -> int:
|
|
original = path.read_text(encoding="utf-8")
|
|
lines = original.splitlines(keepends=True)
|
|
|
|
kept_lines = []
|
|
removed = 0
|
|
|
|
for line in lines:
|
|
if '"icon_png_base64"' in line:
|
|
removed += 1
|
|
continue
|
|
kept_lines.append(line)
|
|
|
|
if removed:
|
|
path.write_text("".join(kept_lines), encoding="utf-8")
|
|
|
|
return removed
|
|
|
|
|
|
def main() -> int:
|
|
parser = argparse.ArgumentParser(
|
|
description="Remove icon_png_base64 fields from atc_chains.json while preserving all other text."
|
|
)
|
|
parser.add_argument(
|
|
"path",
|
|
nargs="?",
|
|
default="atc_chains.json",
|
|
help="Path to the JSON file to rewrite in place.",
|
|
)
|
|
args = parser.parse_args()
|
|
|
|
path = Path(args.path)
|
|
removed = remove_icon_png_base64_lines(path)
|
|
print(f"Removed {removed} icon_png_base64 field(s) from {path}.")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|