MCPcopy Create free account
hub / github.com/ElementsProject/lightning / from_js

Method from_js

contrib/msggen/msggen/model.py:479–510  ·  view source on GitHub ↗
(cls, path, js)

Source from the content-addressed store, hash-verified

477
478 @classmethod
479 def from_js(cls, path, js):
480 # Determine how nested we are
481 dims = 1
482 child_js = js["items"]
483 while child_js.get("type", None) == "array":
484 dims += 1
485 child_js = child_js["items"]
486
487 path += "[]" * dims
488 if 'oneOf' in child_js:
489 assert('type' not in child_js)
490 itemtype = UnionField.from_js(child_js, path)
491
492 elif child_js["type"] == "object":
493 itemtype = CompositeField.from_js(child_js, path)
494
495 elif child_js["type"] == "string" and "enum" in child_js:
496 itemtype = EnumField.from_js(child_js, path)
497
498 elif child_js["type"] in PrimitiveField.types:
499 itemtype = PrimitiveField(
500 child_js["type"],
501 path,
502 child_js.get("description", ""),
503 added=child_js.get("added", None),
504 deprecated=child_js.get("deprecated", None),
505 )
506
507 logger.debug(f"Array path={path} dims={dims}, type={itemtype}")
508 return ArrayField(
509 itemtype, dims=dims, path=path, description=js.get("description", ""), added=js.get('added', None), deprecated=js.get('deprecated', None)
510 )
511
512
513class Command:

Callers

nothing calls this directly

Calls 4

PrimitiveFieldClass · 0.85
ArrayFieldClass · 0.85
getMethod · 0.45
from_jsMethod · 0.45

Tested by

no test coverage detected