MCPcopy Create free account
hub / github.com/datapane/datapane / validate_view_doc

Function validate_view_doc

python-client/src/datapane/common/viewxml_utils.py:34–49  ·  view source on GitHub ↗

Validate the model against the schema, throws an etree.DocumentInvalid if not

(
    xml_str: t.Optional[str] = None, xml_doc: t.Optional[ElementT] = None, quiet: bool = False
)

Source from the content-addressed store, hash-verified

32
33
34def validate_view_doc(
35 xml_str: t.Optional[str] = None, xml_doc: t.Optional[ElementT] = None, quiet: bool = False
36) -> bool:
37 """Validate the model against the schema, throws an etree.DocumentInvalid if not"""
38 assert xml_str or (xml_doc is not None)
39 if xml_str:
40 xml_doc = etree.fromstring(xml_str)
41
42 try:
43 rng_validator.assertValid(xml_doc)
44 return True
45 except DocumentInvalid:
46 if not quiet:
47 xml_str = xml_str if xml_str else etree.tounicode(xml_doc, pretty_print=True)
48 log.error(f"Error validating report document:\n\n{xml_str}\n{rng_validator.error_log}\n")
49 raise
50
51
52def conv_attrib(v: t.Any) -> t.Optional[str]:

Callers 2

post_transformsMethod · 0.90
assert_viewFunction · 0.90

Calls 1

errorMethod · 0.80

Tested by 1

assert_viewFunction · 0.72