42 lines
1.7 KiB
Python
42 lines
1.7 KiB
Python
|
|
import json, urllib.request, urllib.parse
|
||
|
|
from pathlib import Path
|
||
|
|
|
||
|
|
ROOT = Path(r"C:\Users\SJ\.minimax-agent\projects\JEI")
|
||
|
|
env = {}
|
||
|
|
for line in (ROOT / ".env.local").read_text(encoding="utf-8").splitlines():
|
||
|
|
line = line.strip()
|
||
|
|
if line and not line.startswith("#") and "=" in line:
|
||
|
|
k, v = line.split("=", 1)
|
||
|
|
env[k.strip()] = v.strip().strip('"').strip("'")
|
||
|
|
PB = env.get("NEXT_PUBLIC_PB_URL") or env["PB_URL"]
|
||
|
|
TOK = env["PB_TOKEN"]
|
||
|
|
|
||
|
|
def get(path, **q):
|
||
|
|
url = f"{PB}{path}"
|
||
|
|
if q:
|
||
|
|
url += "?" + urllib.parse.urlencode(q)
|
||
|
|
req = urllib.request.Request(url, headers={"Authorization": TOK})
|
||
|
|
with urllib.request.urlopen(req, timeout=60) as r:
|
||
|
|
return json.loads(r.read().decode())
|
||
|
|
|
||
|
|
def dump(cid, rid, label):
|
||
|
|
r = get(f"/api/collections/{cid}/records/{rid}", expand="company,director,attendees")
|
||
|
|
print(f"=== {label} {rid}")
|
||
|
|
for k, v in sorted(r.items()):
|
||
|
|
if k in ("collectionId", "collectionName"):
|
||
|
|
continue
|
||
|
|
s = json.dumps(v, ensure_ascii=False)
|
||
|
|
if len(s) > 220:
|
||
|
|
s = s[:220] + "…"
|
||
|
|
print(f" {k}: {s}")
|
||
|
|
print()
|
||
|
|
|
||
|
|
dump("pbc_266170881", "e0dbxprazb70rqx", "RESOLUTION (signed)")
|
||
|
|
dump("ysterbaard_director_resignations", "8cfie18uhgy0n0o", "RESIGNATION")
|
||
|
|
|
||
|
|
# Does the signed resolution reference the same company/director as the resignation?
|
||
|
|
res = get("/api/collections/pbc_266170881/records/e0dbxprazb70rqx", expand="company")
|
||
|
|
resi = get("/api/collections/ysterbaard_director_resignations/records/8cfie18uhgy0n0o", expand="company,director")
|
||
|
|
print("resolution company:", (res.get("expand") or {}).get("company"))
|
||
|
|
print("resignation company:", (resi.get("expand") or {}).get("company"))
|
||
|
|
print("resignation director:", (resi.get("expand") or {}).get("director"))
|