MCPcopy Create free account
hub / github.com/Graphify-Labs/graphify / _schema_ids

Function _schema_ids

scripts/theme_gate.py:377–400  ·  view source on GitHub ↗

Setting ids declared in the ``{% schema %}`` of a Liquid file (own and block settings).

(text: str)

Source from the content-addressed store, hash-verified

375# --------------------------------------------------------------- definitions
376
377def _schema_ids(text: str) -> set[str]:
378 """Setting ids declared in the ``{% schema %}`` of a Liquid file (own and block settings)."""
379 ids: set[str] = set()
380 m = re.search(r"\{%-?\s*schema\s*-?%\}(.*?)\{%-?\s*endschema\s*-?%\}", text, re.S)
381 if not m:
382 return ids
383 try:
384 data = json.loads(m.group(1))
385 except ValueError:
386 return ids
387
388 def walk(o: object) -> None:
389 if isinstance(o, dict):
390 sid = o.get("id")
391 if isinstance(sid, str) and ("type" in o):
392 ids.add(sid)
393 for v in o.values():
394 walk(v)
395 elif isinstance(o, list):
396 for v in o:
397 walk(v)
398
399 walk(data)
400 return ids
401
402
403def _schema_scoped(text: str) -> tuple[set[str], set[str]]:

Callers

nothing calls this directly

Calls 1

walkFunction · 0.70

Tested by

no test coverage detected