diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2019-01-31 14:54:04 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2019-03-07 09:07:17 +0000 |
commit | 15a0f9d14bcfcead7d778cc11c942279c2c7e7e7 (patch) | |
tree | f0d8749c9590d7aabb5bf4e33e84e21b8f7a1d58 /scripts/flake2tasks.py | |
parent | bc35583099ee728b3d7babb7016c66a4246dafb5 (diff) |
Add flake2tasks.py for converting output of the flake8 Python linter into task files
Change-Id: I85462c9323aaac91076f5025a761a9d1fb7208e4
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'scripts/flake2tasks.py')
-rwxr-xr-x | scripts/flake2tasks.py | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/scripts/flake2tasks.py b/scripts/flake2tasks.py new file mode 100755 index 0000000000..a98cbf69ec --- /dev/null +++ b/scripts/flake2tasks.py @@ -0,0 +1,50 @@ +#!/usr/bin/env python +############################################################################ +# +# Copyright (C) 2019 The Qt Company Ltd. +# Contact: https://www.qt.io/licensing/ +# +# This file is part of Qt Creator. +# +# Commercial License Usage +# Licensees holding valid commercial Qt licenses may use this file in +# accordance with the commercial license agreement provided with the +# Software or, alternatively, in accordance with the terms contained in +# a written agreement between you and The Qt Company. For licensing terms +# and conditions see https://www.qt.io/terms-conditions. For further +# information use the contact form at https://www.qt.io/contact-us. +# +# GNU General Public License Usage +# Alternatively, this file may be used under the terms of the GNU +# General Public License version 3 as published by the Free Software +# Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +# included in the packaging of this file. Please review the following +# information to ensure the GNU General Public License requirements will +# be met: https://www.gnu.org/licenses/gpl-3.0.html. +# +############################################################################ + +''' +flake2tasks.py - Convert flake8 warnings into Qt Creator task files. + +SYNOPSIS + + flake2tasks.py < logfile > taskfile +''' + +import sys +import re + +if __name__ == '__main__': + pattern = re.compile(r'^([^:]+):(\d+):\d+: E\d+ (.*)$') + while True: + line = sys.stdin.readline().rstrip() + if not line: + break + match = pattern.match(line) + if match: + file_name = match.group(1).replace('\\', '/') + line_number = match.group(2) + text = match.group(3) + output = "{}\t{}\twarn\t{}".format(file_name, line_number, text) + print(output) |