143 ldraw_code = ldraw_code, |
143 ldraw_code = ldraw_code, |
144 ) |
144 ) |
145 messages.append(message) |
145 messages.append(message) |
146 return '\n'.join(messages) |
146 return '\n'.join(messages) |
147 |
147 |
148 def format_report(report, model, test_suite): |
|
149 import colorama |
|
150 colorama.init() |
|
151 messages = [] |
|
152 for problem in report['problems']: |
|
153 if problem.severity == 'hold': |
|
154 text_colour = colorama.Fore.LIGHTRED_EX |
|
155 elif problem.severity == 'warning': |
|
156 text_colour = colorama.Fore.LIGHTBLUE_EX |
|
157 else: |
|
158 text_colour = '' |
|
159 ldraw_code = model.body[problem.body_index].textual_representation() |
|
160 message = str.format( |
|
161 '{text_colour}{model_name}:{line_number}: {problem_type}: {message}' |
|
162 '{colour_reset}\n\t{ldraw_code}', |
|
163 text_colour = text_colour, |
|
164 model_name = model.name, |
|
165 line_number = problem.line_number, |
|
166 problem_type = problem.severity, |
|
167 message = problem_text(problem, test_suite), |
|
168 colour_reset = colorama.Fore.RESET, |
|
169 ldraw_code = ldraw_code, |
|
170 ) |
|
171 messages.append(message) |
|
172 return '\n'.join(messages) |
|
173 |
|
174 def iterate_problems(test_suite): |
148 def iterate_problems(test_suite): |
175 for test_function in test_suite['tests']: |
149 for test_function in test_suite['tests']: |
176 yield from test_function.ldcheck_problem_types.values() |
150 yield from test_function.ldcheck_problem_types.values() |
177 |
151 |
178 def all_problem_types(test_suite): |
152 def all_problem_types(test_suite): |