From 00892b3d45fd05f707fd26336154d9016974c144 Mon Sep 17 00:00:00 2001 From: Graham Hayes Date: Tue, 14 Jul 2015 14:04:09 +0100 Subject: [PATCH] Only print flake8 table if there is results Change-Id: I1496280ff5003d507751f04a06b08942c89539da --- tools/pretty_flake8.py | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/tools/pretty_flake8.py b/tools/pretty_flake8.py index 2989f4fe4..2688cccfa 100755 --- a/tools/pretty_flake8.py +++ b/tools/pretty_flake8.py @@ -40,28 +40,30 @@ def main(): else: print(line) - print('Flake8 Results') + if len(raw_errors) > 0: - ct = PrettyTable([ - "File", - "Line", - "Column", - "Error Code", - "Error Message", - "Code" - ]) + print('Flake8 Results') - ct.align["File"] = "l" - ct.align["Error Message"] = "l" - ct.align["Code"] = "l" + ct = PrettyTable([ + "File", + "Line", + "Column", + "Error Code", + "Error Message", + "Code" + ]) - for line in raw_errors: - ct.add_row(format_dict(line)) + ct.align["File"] = "l" + ct.align["Error Message"] = "l" + ct.align["Code"] = "l" - print(ct) + for line in raw_errors: + ct.add_row(format_dict(line)) - with open('flake8_results.html', 'w') as f: - f.write('%s' % ct.get_html_string(attributes = {"cellspacing": 0})) # noqa + print(ct) + + with open('flake8_results.html', 'w') as f: + f.write('%s' % ct.get_html_string(attributes = {"cellspacing": 0})) # noqa def format_dict(raw):