Skip to content

Commit

Permalink
Modify linter regex to work on windows file paths
Browse files Browse the repository at this point in the history
  • Loading branch information
martixy committed May 10, 2018
1 parent dcf4f24 commit 4e4fcb7
Showing 1 changed file with 36 additions and 16 deletions.
52 changes: 36 additions & 16 deletions linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,24 @@ class GfortranFixedForm(Linter):
version_re = r'(?P<version>\d+\.\d+\.\d+)'
version_requirement = '>= 4.0'
multiline = True
regex = (
# filename:line:col: is common for multiline and single line warnings
r'^[^:]*:(?P<line>\d+)[:.](?P<col>\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'(?:(?P<error>Error|Fatal\sError)|(?P<warning>Warning)): (?P<message>.*$)'
)
if (sys.platform == 'win32'):
regex = (
# filename:line:col: is common for multiline and single line warnings
r'^[a-zA-Z]:[^:]*:(?P<line>\d+)[:.](?P<col>\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'(?:(?P<error>Error|Fatal\sError)|(?P<warning>Warning)): (?P<message>.*$)'
)
else:
regex = (
# filename:line:col: is common for multiline and single line warnings
r'^[^:]*:(?P<line>\d+)[:.](?P<col>\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'(?:(?P<error>Error|Fatal\sError)|(?P<warning>Warning)): (?P<message>.*$)'
)
tempfile_suffix = "f"
on_stderr = True

Expand All @@ -44,13 +54,23 @@ class GfortranModern(Linter):
version_re = r'(?P<version>\d+\.\d+\.\d+)'
version_requirement = '>= 4.0'
multiline = True
regex = (
# filename:line:col: is common for multiline and single line warnings
r'^[^:]*:(?P<line>\d+)[:.](?P<col>\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'(?:(?P<error>Error|Fatal\sError)|(?P<warning>Warning)): (?P<message>.*$)'
)
if (sys.platform == 'win32'):
regex = (
# filename:line:col: is common for multiline and single line warnings
r'^[a-zA-Z]:[^:]*:(?P<line>\d+)[:.](?P<col>\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'(?:(?P<error>Error|Fatal\sError)|(?P<warning>Warning)): (?P<message>.*$)'
)
else:
regex = (
# filename:line:col: is common for multiline and single line warnings
r'^[^:]*:(?P<line>\d+)[:.](?P<col>\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'(?:(?P<error>Error|Fatal\sError)|(?P<warning>Warning)): (?P<message>.*$)'
)
tempfile_suffix = "f90"
on_stderr = True

0 comments on commit 4e4fcb7

Please sign in to comment.