sarkit.verification.CrsdConsistency.from_file

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

Create a CrsdConsistency object from a file

Parameters:
filefile object

CRSD or CRSD 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 CRSD XML.

Returns:
CrsdConsistency

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-crsd-1.0.xml", "r") as f:
...     con = skver.CrsdConsistency.from_file(f)
>>> con.check()
>>> bool(con.passes())
True
>>> bool(con.failures())
False

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

>>> with file.open("rb") as f:
...     con_thorough = skver.CrsdConsistency.from_file(f, thorough=True)
...     con = skver.CrsdConsistency.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