sarkit.verification.CrsdConsistency.from_file
- static CrsdConsistency.from_file(file, schema=None, thorough=False)
Create a CrsdConsistency object from a file
- Parameters:
- file
file object CRSD or CRSD XML file to check
- schema
str, 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.
- file
- Returns:
CrsdConsistencyThe initialized consistency checker object
See also
Examples
Use
from_fileto 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_fileto 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