sarkit.verification.CphdConsistency.from_file

static CphdConsistency.from_file(file, schema=None, thorough=False)

Create a CphdConsistency object from a file

Parameters:
filefile object

CPHD or CPHD XML file to check

schemastr, optional

Path to XML Schema. If None, tries to find a version-specific schema

thoroughbool, optional

Run checks that may seek/read through large portions of the file. file must stay open to run checks. Ignored if file is CPHD XML.

Returns:
CphdConsistency

The initialized consistency checker object

See also

from_parts

Examples

Use from_file to check an XML file:

>>> import sarkit.verification as skver

>>> with open("data/example-cphd-1.1.0.xml", "r") as f:
...     con = skver.CphdConsistency.from_file(f)
>>> con.check()
>>> bool(con.passes())
True
>>> bool(con.failures())
False

Use from_file to check a CPHD file, with and without thorough checks:

>>> with file.open("rb") as f:
...     con_thorough = skver.CphdConsistency.from_file(f, thorough=True)
...     con = skver.CphdConsistency.from_file(f)
...     con_thorough.check()  # thorough checks require open file
>>> con.check()  # without thorough, open file only used for construction
>>> print(len(con.skips()) > len(con_thorough.skips()))
True