Skip to content

Commit ff348aa

Browse files
committed
Polish remove_links migration script
1 parent 756f755 commit ff348aa

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

scripts/migrations/remove_links.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
11
# This script removes occurrences of `links` in room files.
2-
2+
#
3+
# To use, run "PYTHONPATH=. python migrations/remove_links.py"
4+
# from a working directory of "sm-json-data/scripts".
35
import json
46
from pathlib import Path
5-
import copy
6-
7+
import argparse
78
import format_json
89

10+
argparser = argparse.ArgumentParser()
11+
argparser.add_argument("--path", type=Path, default="../region", help="Path to the region directory")
12+
args = argparser.parse_args()
913

10-
for path in sorted(Path("../../region").glob("**/*.json")):
14+
if not args.path.exists():
15+
raise FileNotFoundError(f"Path {args.path} does not exist")
16+
for path in sorted(args.path.glob("**/*.json")):
1117
room_json = json.load(path.open("r"))
12-
if room_json.get("$schema") != "../../../schema/m3-room.schema.json":
18+
schema = room_json.get("$schema")
19+
if schema is None or schema.split("/")[-1] != "m3-room.schema.json":
1320
continue
1421
print("Processing", path)
1522
del room_json["links"]

0 commit comments

Comments
 (0)