From 4e4fcb703ca6009fa6881aaa1cb9c26cf4cd60f7 Mon Sep 17 00:00:00 2001 From: martixy Date: Thu, 10 May 2018 12:38:37 +0300 Subject: [PATCH] Modify linter regex to work on windows file paths Fixes #28, #37 --- linter.py | 52 ++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 16 deletions(-) diff --git a/linter.py b/linter.py index bb2aba5..f3b0e4a 100644 --- a/linter.py +++ b/linter.py @@ -24,14 +24,24 @@ class GfortranFixedForm(Linter): version_re = r'(?P\d+\.\d+\.\d+)' version_requirement = '>= 4.0' multiline = True - regex = ( - # filename:line:col: is common for multiline and single line warnings - r'^[^:]*:(?P\d+)[:.](?P\d+):' - # Then we either have a space or (a newline, a newline, some source code, a newline, a col number, a newline) - r'(?:\s|$\r?\n^$\r?\n^.*$\r?\n^\s*\d$\r?\n)' - # Finally we have (Error|Warning): message to the end of the line - r'(?:(?PError|Fatal\sError)|(?PWarning)): (?P.*$)' - ) + if (sys.platform == 'win32'): + regex = ( + # filename:line:col: is common for multiline and single line warnings + r'^[a-zA-Z]:[^:]*:(?P\d+)[:.](?P\d+):' + # Then we either have a space or (a newline, a newline, some source code, a newline, a col number, a newline) + r'(?:\s|$\r?\n^$\r?\n^.*$\r?\n^\s*\d$\r?\n)' + # Finally we have (Error|Warning): message to the end of the line + r'(?:(?PError|Fatal\sError)|(?PWarning)): (?P.*$)' + ) + else: + regex = ( + # filename:line:col: is common for multiline and single line warnings + r'^[^:]*:(?P\d+)[:.](?P\d+):' + # Then we either have a space or (a newline, a newline, some source code, a newline, a col number, a newline) + r'(?:\s|$\r?\n^$\r?\n^.*$\r?\n^\s*\d$\r?\n)' + # Finally we have (Error|Warning): message to the end of the line + r'(?:(?PError|Fatal\sError)|(?PWarning)): (?P.*$)' + ) tempfile_suffix = "f" on_stderr = True @@ -44,13 +54,23 @@ class GfortranModern(Linter): version_re = r'(?P\d+\.\d+\.\d+)' version_requirement = '>= 4.0' multiline = True - regex = ( - # filename:line:col: is common for multiline and single line warnings - r'^[^:]*:(?P\d+)[:.](?P\d+):' - # Then we either have a space or (a newline, a newline, some source code, a newline, a col number, a newline) - r'(?:\s|$\r?\n^$\r?\n^.*$\r?\n^\s*\d$\r?\n)' - # Finally we have (Error|Warning): message to the end of the line - r'(?:(?PError|Fatal\sError)|(?PWarning)): (?P.*$)' - ) + if (sys.platform == 'win32'): + regex = ( + # filename:line:col: is common for multiline and single line warnings + r'^[a-zA-Z]:[^:]*:(?P\d+)[:.](?P\d+):' + # Then we either have a space or (a newline, a newline, some source code, a newline, a col number, a newline) + r'(?:\s|$\r?\n^$\r?\n^.*$\r?\n^\s*\d$\r?\n)' + # Finally we have (Error|Warning): message to the end of the line + r'(?:(?PError|Fatal\sError)|(?PWarning)): (?P.*$)' + ) + else: + regex = ( + # filename:line:col: is common for multiline and single line warnings + r'^[^:]*:(?P\d+)[:.](?P\d+):' + # Then we either have a space or (a newline, a newline, some source code, a newline, a col number, a newline) + r'(?:\s|$\r?\n^$\r?\n^.*$\r?\n^\s*\d$\r?\n)' + # Finally we have (Error|Warning): message to the end of the line + r'(?:(?PError|Fatal\sError)|(?PWarning)): (?P.*$)' + ) tempfile_suffix = "f90" on_stderr = True