MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / build_command

Function build_command

py/generate_bidi_protocol.py:791–817  ·  view source on GitHub ↗
(schema: Schema, cmd: dict)

Source from the content-addressed store, hash-verified

789
790
791def build_command(schema: Schema, cmd: dict) -> CommandIR:
792 params = schema.params_for(cmd.get("params"))
793 if cmd.get("params") and params is None:
794 raise ValueError(f"command {cmd['method']} has params that cannot be expressed as a typed object")
795 params_ref = (cmd.get("params") or {}).get("ref")
796 kind = schema.type_kind(params_ref)
797 params_class = type_class_name(params_ref) if params and kind in _PARAMS_CLASS_KINDS else None
798 result_ref = (cmd.get("result") or {}).get("ref")
799 result_name = schema.structured_ref(result_ref) if result_ref else None
800 _guard_same_domain(cmd["domain"], params_ref if params_class else None, result_name, cmd["method"])
801 result_class = type_class_name(result_name) if result_name else None
802 if result_name and schema.type_kind(result_name) == "union":
803 result_type = value_alias(result_name)
804 elif result_class:
805 result_type = result_class
806 else:
807 result_type = "Any"
808 return CommandIR(
809 wire=cmd["method"],
810 method=safe_name(camel_to_snake(cmd["name"])),
811 params=params or [],
812 params_class=params_class,
813 union_params=(kind == "union"),
814 result_class=result_class,
815 result_type=result_type,
816 spec_href=cmd.get("specHref"),
817 )
818
819
820def build_event(schema: Schema, event: dict) -> EventIR:

Callers 2

build_irMethod · 0.85
build_moduleFunction · 0.85

Calls 10

type_class_nameFunction · 0.85
_guard_same_domainFunction · 0.85
value_aliasFunction · 0.85
CommandIRClass · 0.85
safe_nameFunction · 0.85
camel_to_snakeFunction · 0.85
getMethod · 0.65
params_forMethod · 0.45
type_kindMethod · 0.45
structured_refMethod · 0.45

Tested by

no test coverage detected