6.NUR/nur/format_manifest.py
Erik Oosting 1ca26c0822
Revert "Update local branch (#1)" (#2)
This reverts commit e1e51f0d17.
2020-12-31 17:12:46 +01:00

25 lines
714 B
Python

import json
import shutil
import sys
from argparse import Namespace
from .path import ROOT
def format_manifest_command(args: Namespace) -> None:
path = ROOT.joinpath("repos.json")
manifest = json.load(open(path))
for name, repo in manifest.get("repos", []).items():
if "url" not in repo:
print(f"{name} has no url", file=sys.stderr)
sys.exit(1)
if "github-contact" not in repo:
print(f"{name} has no github contact", file=sys.stderr)
sys.exit(1)
tmp_path = str(path) + ".tmp"
with open(tmp_path, "w+") as tmp:
json.dump(manifest, tmp, indent=4, sort_keys=True)
tmp.write("\n")
shutil.move(tmp_path, path)