Skip to content

Commit bdca9a9

Browse files
committed
Improve codec script
1 parent 3afc896 commit bdca9a9

File tree

1 file changed

+10
-16
lines changed

1 file changed

+10
-16
lines changed

codec/validate.py

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,22 @@
11
#!/usr/bin/env python
22

3-
from pathlib import Path
43
import asn1tools
4+
import glob
55
import os
66
import sys
77

88
script_dir = os.path.dirname(os.path.abspath(__file__))
99
sys.path.append(os.path.abspath(os.path.join(script_dir, '../jam-types-asn')))
10-
print(sys.path)
10+
11+
from utils import get_schema_files, validate # noqa: E402
1112

1213
os.chdir(script_dir)
1314

14-
from utils import get_schema_files, validate
15+
def validate_spec(spec_name, is_full):
16+
print(f"[Validating '{spec_name}' spec]")
17+
schema = asn1tools.compile_files(get_schema_files(is_full), codec="jer")
18+
for json_file in glob.glob(f"{spec_name}/*.json"):
19+
validate(schema, json_file)
1520

16-
# Validate tiny
17-
print("[Validating Tiny Spec]")
18-
schema = asn1tools.compile_files(get_schema_files(False), codec="jer")
19-
for path in Path("tiny").iterdir():
20-
if path.is_file() and path.suffix == ".json":
21-
validate(schema, path)
22-
23-
# Validate full
24-
print("[Validating Full Spec]")
25-
schema = asn1tools.compile_files(get_schema_files(True), codec="jer")
26-
for path in Path("full").iterdir():
27-
if path.is_file() and path.suffix == ".json":
28-
validate(schema, path)
21+
validate_spec("tiny", False)
22+
validate_spec("full", True)

0 commit comments

Comments
 (0)