-
Notifications
You must be signed in to change notification settings - Fork 6
/
validate_main.py
48 lines (39 loc) · 1.63 KB
/
validate_main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
from .sraparse import SRAParseObjSet, SRAParseObj, XMLValidator
from .utils import cmn, json2, logger
from . import io_adaptor
from . import utils
class ValidatorTemplate:
def __init__(self, objtype):
self.nObj = 0
self.validated = list()
self.objtype = objtype
self.objset = self.objtype + '_SET'
self.validator_log = dict()
self.versioned_xml = list()
self.validated = list()
def main(args, versioned_xml, validated, nObjs, validator, xml_validator):
validated_xml_file = cmn.writel(args['-out'], versioned_xml)
print ('written:' + validated_xml_file)
print ('validated:', len(validated))
print ('failed:', nObjs - len(validated))
if validated:
validated_xml_set = SRAParseObjSet.from_file(validated_xml_file)
if not (validated_xml_set.is_valid__xml(xml_validator) or args.has("-skip-updated-xml-validation")):
utils.sanity_check_fail('__xml_validation_failed__')
logger('ok\n')
else:
logger('..no valid objects found\n')
errlog = { e : v.errorlog for e, v in validator.items()}
semanticlog = { e : v.semanticlog for e, v in validator.items()}
errlog = io_adaptor.format_errlog(errlog)
collected = io_adaptor.collectreports({"versioning":errlog, "semantic_rules": semanticlog})
if args.has('-jsonlog'):
print(json2.dumpf(args['-jsonlog'] + '.err.json', errlog))
print(json2.dumpf(args['-jsonlog'] + '.sem.json', semanticlog))
print(json2.dumpf(args['-jsonlog'] + '.raw.json', collected))
better_errors = io_adaptor.better_errors(collected)
print(json2.dumpf(args['-jsonlog'], better_errors))
else:
better_errors = io_adaptor.better_errors(collected)
json2.pp(better_errors)
return better_errors