# HG changeset patch # User Teemu Piippo # Date 1598382604 -10800 # Node ID 01941a811b5ad373eeb0dc95886dd7b5a5f02ecf # Parent f9d4e59392f7e93e0b60d1001b45927b2e06ac45 move format_report_html to webfront.py diff -r f9d4e59392f7 -r 01941a811b5a testsuite.py --- a/testsuite.py Tue Aug 25 22:08:30 2020 +0300 +++ b/testsuite.py Tue Aug 25 22:10:04 2020 +0300 @@ -129,22 +129,6 @@ message = message(**problem.args) return message -def format_report_html(report, model, test_suite): - messages = [] - for problem in report['problems']: - ldraw_code = model.body[problem.body_index].textual_representation() - message = str.format( - '
  • {model_name}:{line_number}:' - '{problem_type}: {message}
    {ldraw_code}
  • ', - model_name = model.name, - line_number = problem.line_number, - problem_type = problem.severity, - message = problem_text(problem, test_suite), - ldraw_code = ldraw_code, - ) - messages.append(message) - return '\n'.join(messages) - def iterate_problems(test_suite): for test_function in test_suite['tests']: yield from test_function.ldcheck_problem_types.values() @@ -154,7 +138,6 @@ iterate_problems(test_suite), key = lambda problem_type: problem_type.name ) - if __name__ == '__main__': from pprint import pprint diff -r f9d4e59392f7 -r 01941a811b5a webfront.py --- a/webfront.py Tue Aug 25 22:08:30 2020 +0300 +++ b/webfront.py Tue Aug 25 22:10:04 2020 +0300 @@ -6,6 +6,22 @@ app = Flask('LDCheck') +def format_report_html(report, model, test_suite): + messages = [] + for problem in report['problems']: + ldraw_code = model.body[problem.body_index].textual_representation() + message = str.format( + '
  • {model_name}:{line_number}:' + '{problem_type}: {message}
    {ldraw_code}
  • ', + model_name = model.name, + line_number = problem.line_number, + problem_type = problem.severity, + message = problem_text(problem, test_suite), + ldraw_code = ldraw_code, + ) + messages.append(message) + return '\n'.join(messages) + @app.route('/', methods = ['GET', 'POST']) def web_front(): test_suite = load_tests()