@@ -33,19 +33,14 @@ def setup_check_args(parser):
33
33
def validate_check_args (parser , args ):
34
34
spec_fn = args .yaml
35
35
o = args .o
36
- schema_fn = path .join (path .dirname (__file__ ), "schema/seqspec.schema.json" )
37
36
38
- return run_check (schema_fn , spec_fn , o )
37
+ return run_check (spec_fn , o )
39
38
40
39
41
- def run_check (schema_fn , spec_fn , o ):
40
+ def run_check (spec_fn , o ):
42
41
spec = load_spec (spec_fn )
43
42
44
- with open (schema_fn , "r" ) as stream :
45
- schema = yaml .load (stream , Loader = yaml .Loader )
46
- v = Draft4Validator (schema )
47
-
48
- errors = check (v , spec , spec_fn )
43
+ errors = check (spec )
49
44
50
45
if errors :
51
46
if o :
@@ -56,14 +51,19 @@ def run_check(schema_fn, spec_fn, o):
56
51
return errors
57
52
58
53
59
- def check (schema : Draft4Validator , spec : Assay , spec_fn : str ):
54
+ def check (spec : Assay , spec_fn : str = None ):
55
+ schema_fn = path .join (path .dirname (__file__ ), "schema/seqspec.schema.json" )
56
+
57
+ with open (schema_fn , "r" ) as stream :
58
+ schema = yaml .load (stream , Loader = yaml .Loader )
59
+ validator = Draft4Validator (schema )
60
60
errors = []
61
61
idx = 0
62
62
63
63
# with open("del.json", "w") as f:
64
64
# json.dump(spec.to_dict(), f, indent=4)
65
65
66
- for idx , error in enumerate (schema .iter_errors (spec .to_dict ()), 1 ):
66
+ for idx , error in enumerate (validator .iter_errors (spec .to_dict ()), 1 ):
67
67
errors .append (
68
68
f"[error { idx } ] { error .message } in spec[{ '][' .join (repr (index ) for index in error .path )} ]"
69
69
)
0 commit comments