69 yield from self.filter_by_type(linetypes.Triangle) |
69 yield from self.filter_by_type(linetypes.Triangle) |
70 @property |
70 @property |
71 def quadrilaterals(self): |
71 def quadrilaterals(self): |
72 yield from self.filter_by_type(linetypes.Quadrilateral) |
72 yield from self.filter_by_type(linetypes.Quadrilateral) |
73 |
73 |
|
74 import argparse |
|
75 class ListTestSuiteAction(argparse.Action): |
|
76 def __init__(self, option_strings, dest, nargs = None, **kwargs): |
|
77 super().__init__(option_strings, dest, nargs = 0, **kwargs) |
|
78 def __call__(self, *args, **kwargs): |
|
79 from testsuite import load_tests |
|
80 from sys import exit |
|
81 from re import sub |
|
82 test_suite = load_tests() |
|
83 for test_name in sorted(test_suite['tests'].keys()): |
|
84 test_function = test_suite['tests'][test_name] |
|
85 help = sub(r'\s+', ' ', test_function.__doc__ or '').strip() |
|
86 print(test_name + ': ' + help) |
|
87 exit(0) |
|
88 |
74 if __name__ == '__main__': |
89 if __name__ == '__main__': |
75 from sys import argv |
90 from sys import argv |
|
91 parser = argparse.ArgumentParser() |
|
92 parser.add_argument('filename') |
|
93 parser.add_argument('--list', |
|
94 action = ListTestSuiteAction, |
|
95 help = 'Lists all possible checks and exit', |
|
96 ) |
|
97 args = parser.parse_args() |
76 config = load_config('ldcheck.cfg') |
98 config = load_config('ldcheck.cfg') |
77 for ldconfig_ldr_path in find_ldconfig_ldr_paths(config): |
99 for ldconfig_ldr_path in find_ldconfig_ldr_paths(config): |
78 with ldconfig_ldr_path.open() as ldconfig_ldr: |
100 with ldconfig_ldr_path.open() as ldconfig_ldr: |
79 load_colours(ldconfig_ldr) |
101 load_colours(ldconfig_ldr) |
80 with open(argv[1], 'r') as file: |
102 with open(args.filename) as file: |
81 from os.path import basename |
103 from os.path import basename |
82 model = read_ldraw(file, name = basename(argv[1]), config = config) |
104 model = read_ldraw( |
|
105 file, |
|
106 name = basename(args.filename), |
|
107 config = config, |
|
108 ) |
83 from testsuite import load_tests, check_model, format_report |
109 from testsuite import load_tests, check_model, format_report |
84 test_suite = load_tests() |
110 test_suite = load_tests() |
85 report = check_model(model, test_suite) |
111 report = check_model(model, test_suite) |
86 print(format_report(report, model, test_suite)) |
112 print(format_report(report, model, test_suite)) |