app
SOLIDWORKS Bridge
Public Made by Adomby adom
Launch, model and quit SOLIDWORKS from any Adom container. Nothing is ever lost.
main
#!/usr/bin/env python3
"""page.json carries what the wiki page shows that package.json owns: tags and
discovery triggers (0.9.12 — the page showed `tags: []`). Run with no argument
to write page.json; `--check` exits 1 if it is out of sync (release.sh runs
that before it publishes anything)."""
import json, os, sys
ROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..")
FIELDS = ("tags", "discovery_triggers")
def wanted():
pkg = json.load(open(os.path.join(ROOT, "package.json")))
page = json.load(open(os.path.join(ROOT, "page.json")))
out = dict(page)
for f in FIELDS:
if f in pkg:
out[f] = pkg[f]
return page, out
def main():
page, out = wanted()
if "--check" in sys.argv:
drift = [f for f in FIELDS if page.get(f) != out.get(f)]
if drift:
print("page.json out of sync with package.json: %s" % ", ".join(drift))
return 1
return 0
with open(os.path.join(ROOT, "page.json"), "w") as fh:
json.dump(out, fh, indent=2, ensure_ascii=False)
fh.write("\n")
print("page.json synced: %s" % ", ".join(FIELDS))
return 0
if __name__ == "__main__":
sys.exit(main())