-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy path__main__.py
More file actions
33 lines (29 loc) · 1.1 KB
/
__main__.py
File metadata and controls
33 lines (29 loc) · 1.1 KB
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
import sys
import json
import argparse
from . import parse, CollectedValidationErrors
def main():
parser = argparse.ArgumentParser(description="Parse and validate STEP file.")
parser.add_argument("filename", help="The STEP file to validate.")
parser.add_argument("--progress", action="store_true", help="Show progress during validation.")
parser.add_argument("--json", action="store_true", help="Output errors in JSON format.")
parser.add_argument("--only-header", action="store_true", help="Validate only the header section.")
args = parser.parse_args()
try:
parse(
filename=args.filename,
with_progress = args.progress,
with_tree = False,
only_header=args.only_header,
)
if not args.json:
print("Valid", file=sys.stderr)
exit(0)
except CollectedValidationErrors as exc:
if not args.json:
print(exc, file=sys.stderr)
else:
json.dump([e.asdict() for e in exc.errors], sys.stdout, indent=2)
exit(1)
if __name__ == '__main__':
main()