3 from ldcheck import load_config, load_colours, find_ldconfig_ldr_paths |
3 from ldcheck import load_config, load_colours, find_ldconfig_ldr_paths |
4 from parse import read_ldraw |
4 from parse import read_ldraw |
5 from testsuite import load_tests, check_model, problem_text, all_problem_types |
5 from testsuite import load_tests, check_model, problem_text, all_problem_types |
6 |
6 |
7 app = Flask('LDCheck') |
7 app = Flask('LDCheck') |
|
8 |
|
9 def format_report_html(report, model, test_suite): |
|
10 messages = [] |
|
11 for problem in report['problems']: |
|
12 ldraw_code = model.body[problem.body_index].textual_representation() |
|
13 message = str.format( |
|
14 '<li class="{problem_type}">{model_name}:{line_number}:' |
|
15 '{problem_type}: {message}<br />{ldraw_code}</li>', |
|
16 model_name = model.name, |
|
17 line_number = problem.line_number, |
|
18 problem_type = problem.severity, |
|
19 message = problem_text(problem, test_suite), |
|
20 ldraw_code = ldraw_code, |
|
21 ) |
|
22 messages.append(message) |
|
23 return '\n'.join(messages) |
8 |
24 |
9 @app.route('/', methods = ['GET', 'POST']) |
25 @app.route('/', methods = ['GET', 'POST']) |
10 def web_front(): |
26 def web_front(): |
11 test_suite = load_tests() |
27 test_suite = load_tests() |
12 if request.method == 'POST': |
28 if request.method == 'POST': |