Sat, 03 Feb 2018 17:40:17 +0100
Fix for the second conflict markers regexp.
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
2 | |
6048
82ad8ec9548c
Updated copyright for 2018.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5762
diff
changeset
|
3 | # Copyright (c) 2011 - 2018 Detlev Offenbach <detlev@die-offenbachs.de> |
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
4 | # |
3173
1fb284abe46e
Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3159
diff
changeset
|
5 | # pylint: disable=C0103 |
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
6 | |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
7 | """ |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
8 | Module implementing the syntax check for Python 2/3. |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
9 | """ |
4543
2e6a880670e9
Fixed a few code style issues (forgotten future imports, copyrights,...).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4385
diff
changeset
|
10 | |
5683
66b11f5171e8
Fixed an issue causing eric to not start with Python2 anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5672
diff
changeset
|
11 | try: # Only for Py2 |
66b11f5171e8
Fixed an issue causing eric to not start with Python2 anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5672
diff
changeset
|
12 | import Queue as queue |
66b11f5171e8
Fixed an issue causing eric to not start with Python2 anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5672
diff
changeset
|
13 | except ImportError: |
66b11f5171e8
Fixed an issue causing eric to not start with Python2 anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5672
diff
changeset
|
14 | import queue |
66b11f5171e8
Fixed an issue causing eric to not start with Python2 anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5672
diff
changeset
|
15 | |
3525
66f4b8646622
Reintegrated the js syntax checker and therefore improved the background service a little.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3515
diff
changeset
|
16 | import ast |
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
17 | import re |
3159
02cb2adb4868
First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3065
diff
changeset
|
18 | import sys |
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
19 | import traceback |
4231
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
20 | import multiprocessing |
5683
66b11f5171e8
Fixed an issue causing eric to not start with Python2 anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5672
diff
changeset
|
21 | |
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
22 | |
3173
1fb284abe46e
Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3159
diff
changeset
|
23 | try: |
1fb284abe46e
Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3159
diff
changeset
|
24 | from pyflakes.checker import Checker |
5363
cbe61c2f9772
Extended the code of the flakes checker plug-in to really ignore the * imports warnings, if configured that way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
25 | from pyflakes.messages import ImportStarUsed, ImportStarUsage |
3173
1fb284abe46e
Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3159
diff
changeset
|
26 | except ImportError: |
1fb284abe46e
Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3159
diff
changeset
|
27 | pass |
1fb284abe46e
Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3159
diff
changeset
|
28 | |
6107
78dabf542c6b
Extended the check for VCS conflict markers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
29 | VcsConflictMarkerRegExpList = ( |
78dabf542c6b
Extended the check for VCS conflict markers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
30 | re.compile( |
78dabf542c6b
Extended the check for VCS conflict markers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
31 | r"""^<<<<<<< .*?=======.*?>>>>>>> .*?$""", |
78dabf542c6b
Extended the check for VCS conflict markers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
32 | re.MULTILINE | re.DOTALL |
78dabf542c6b
Extended the check for VCS conflict markers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
33 | ), |
78dabf542c6b
Extended the check for VCS conflict markers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
34 | re.compile( |
6108
59cf5a66b0b3
Fix for the second conflict markers regexp.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6107
diff
changeset
|
35 | r"""^<<<<<<< .*?||||||| .*?=======.*?>>>>>>> .*?$""", |
6107
78dabf542c6b
Extended the check for VCS conflict markers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
36 | re.MULTILINE | re.DOTALL |
78dabf542c6b
Extended the check for VCS conflict markers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
37 | ) |
78dabf542c6b
Extended the check for VCS conflict markers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
38 | ) |
3173
1fb284abe46e
Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3159
diff
changeset
|
39 | |
1fb284abe46e
Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3159
diff
changeset
|
40 | def initService(): |
1fb284abe46e
Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3159
diff
changeset
|
41 | """ |
1fb284abe46e
Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3159
diff
changeset
|
42 | Initialize the service and return the entry point. |
1fb284abe46e
Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3159
diff
changeset
|
43 | |
1fb284abe46e
Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3159
diff
changeset
|
44 | @return the entry point for the background client (function) |
1fb284abe46e
Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3159
diff
changeset
|
45 | """ |
1fb284abe46e
Interface to add user-defined services, e.g. in plugins. Auto syntax check working. Little cleanup.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3159
diff
changeset
|
46 | return syntaxAndPyflakesCheck |
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
47 | |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
48 | |
4231
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
49 | def initBatchService(): |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
50 | """ |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
51 | Initialize the batch service and return the entry point. |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
52 | |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
53 | @return the entry point for the background client (function) |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
54 | """ |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
55 | return syntaxAndPyflakesBatchCheck |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
56 | |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
57 | |
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
58 | def normalizeCode(codestring): |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
59 | """ |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
60 | Function to normalize the given code. |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
61 | |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
62 | @param codestring code to be normalized (string) |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
63 | @return normalized code (string) |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
64 | """ |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
65 | codestring = codestring.replace("\r\n", "\n").replace("\r", "\n") |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
66 | |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
67 | if codestring and codestring[-1] != '\n': |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
68 | codestring = codestring + '\n' |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
69 | |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
70 | # Check type for py2: if not str it's unicode |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
71 | if sys.version_info[0] == 2: |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
72 | try: |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
73 | codestring = codestring.encode('utf-8') |
3159
02cb2adb4868
First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3065
diff
changeset
|
74 | except UnicodeError: |
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
75 | pass |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
76 | |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
77 | return codestring |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
78 | |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
79 | |
5586
0e5421d679e7
Added capability to place line flags (e.g. __IGNORE...) on the line following the one to be ignored.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
80 | def extractLineFlags(line, startComment="#", endComment="", flagsLine=False): |
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
81 | """ |
3065
070b35dde35e
Fixed a bunch of indentation issues.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
2571
diff
changeset
|
82 | Function to extract flags starting and ending with '__' from a line |
070b35dde35e
Fixed a bunch of indentation issues.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
2571
diff
changeset
|
83 | comment. |
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
84 | |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
85 | @param line line to extract flags from (string) |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
86 | @keyparam startComment string identifying the start of the comment (string) |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
87 | @keyparam endComment string identifying the end of a comment (string) |
5586
0e5421d679e7
Added capability to place line flags (e.g. __IGNORE...) on the line following the one to be ignored.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
88 | @keyparam flagsLine flag indicating to check for a flags only line (bool) |
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
89 | @return list containing the extracted flags (list of strings) |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
90 | """ |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
91 | flags = [] |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
92 | |
5586
0e5421d679e7
Added capability to place line flags (e.g. __IGNORE...) on the line following the one to be ignored.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
93 | if not flagsLine or ( |
0e5421d679e7
Added capability to place line flags (e.g. __IGNORE...) on the line following the one to be ignored.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
94 | flagsLine and line.strip().startswith(startComment)): |
0e5421d679e7
Added capability to place line flags (e.g. __IGNORE...) on the line following the one to be ignored.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
95 | pos = line.rfind(startComment) |
0e5421d679e7
Added capability to place line flags (e.g. __IGNORE...) on the line following the one to be ignored.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
96 | if pos >= 0: |
0e5421d679e7
Added capability to place line flags (e.g. __IGNORE...) on the line following the one to be ignored.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
97 | comment = line[pos + len(startComment):].strip() |
0e5421d679e7
Added capability to place line flags (e.g. __IGNORE...) on the line following the one to be ignored.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
98 | if endComment: |
0e5421d679e7
Added capability to place line flags (e.g. __IGNORE...) on the line following the one to be ignored.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
99 | endPos = line.rfind(endComment) |
0e5421d679e7
Added capability to place line flags (e.g. __IGNORE...) on the line following the one to be ignored.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
100 | if endPos >= 0: |
0e5421d679e7
Added capability to place line flags (e.g. __IGNORE...) on the line following the one to be ignored.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
101 | comment = comment[:endPos] |
0e5421d679e7
Added capability to place line flags (e.g. __IGNORE...) on the line following the one to be ignored.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
102 | flags = [f.strip() for f in comment.split() |
0e5421d679e7
Added capability to place line flags (e.g. __IGNORE...) on the line following the one to be ignored.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
103 | if (f.startswith("__") and f.endswith("__"))] |
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
104 | return flags |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
105 | |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
106 | |
3412
9364dab2d472
Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3228
diff
changeset
|
107 | def syntaxAndPyflakesCheck(filename, codestring, checkFlakes=True, |
3159
02cb2adb4868
First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3065
diff
changeset
|
108 | ignoreStarImportWarnings=False): |
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
109 | """ |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
110 | Function to compile one Python source file to Python bytecode |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
111 | and to perform a pyflakes check. |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
112 | |
3159
02cb2adb4868
First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3065
diff
changeset
|
113 | @param filename source filename (string) |
3412
9364dab2d472
Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3228
diff
changeset
|
114 | @param codestring string containing the code to compile (string) |
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
115 | @keyparam checkFlakes flag indicating to do a pyflakes check (boolean) |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
116 | @keyparam ignoreStarImportWarnings flag indicating to |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
117 | ignore 'star import' warnings (boolean) |
3412
9364dab2d472
Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3228
diff
changeset
|
118 | @return dictionary with the keys 'error' and 'warnings' which |
9364dab2d472
Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3228
diff
changeset
|
119 | hold a list containing details about the error/ warnings |
9364dab2d472
Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3228
diff
changeset
|
120 | (file name, line number, column, codestring (only at syntax |
9364dab2d472
Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3228
diff
changeset
|
121 | errors), the message, a list with arguments for the message) |
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
122 | """ |
4231
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
123 | return __syntaxAndPyflakesCheck(filename, codestring, checkFlakes, |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
124 | ignoreStarImportWarnings) |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
125 | |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
126 | |
5762
76ef5f340007
Added functionality to limit the number of processes used for bachground services.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5683
diff
changeset
|
127 | def syntaxAndPyflakesBatchCheck(argumentsList, send, fx, cancelled, |
76ef5f340007
Added functionality to limit the number of processes used for bachground services.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5683
diff
changeset
|
128 | maxProcesses=0): |
4231
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
129 | """ |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
130 | Module function to check syntax for a batch of files. |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
131 | |
4236
8d4e498a7af8
Fixed a few coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4231
diff
changeset
|
132 | @param argumentsList list of arguments tuples as given for |
4231
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
133 | syntaxAndPyflakesCheck |
5762
76ef5f340007
Added functionality to limit the number of processes used for bachground services.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5683
diff
changeset
|
134 | @type list |
76ef5f340007
Added functionality to limit the number of processes used for bachground services.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5683
diff
changeset
|
135 | @param send reference to send function |
76ef5f340007
Added functionality to limit the number of processes used for bachground services.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5683
diff
changeset
|
136 | @type func |
76ef5f340007
Added functionality to limit the number of processes used for bachground services.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5683
diff
changeset
|
137 | @param fx registered service name |
76ef5f340007
Added functionality to limit the number of processes used for bachground services.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5683
diff
changeset
|
138 | @type str |
4231
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
139 | @param cancelled reference to function checking for a cancellation |
5762
76ef5f340007
Added functionality to limit the number of processes used for bachground services.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5683
diff
changeset
|
140 | @type func |
76ef5f340007
Added functionality to limit the number of processes used for bachground services.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5683
diff
changeset
|
141 | @param maxProcesses number of processes to be used |
76ef5f340007
Added functionality to limit the number of processes used for bachground services.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5683
diff
changeset
|
142 | @type int |
4231
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
143 | """ |
5762
76ef5f340007
Added functionality to limit the number of processes used for bachground services.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5683
diff
changeset
|
144 | if maxProcesses == 0: |
76ef5f340007
Added functionality to limit the number of processes used for bachground services.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5683
diff
changeset
|
145 | # determine based on CPU count |
76ef5f340007
Added functionality to limit the number of processes used for bachground services.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5683
diff
changeset
|
146 | try: |
76ef5f340007
Added functionality to limit the number of processes used for bachground services.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5683
diff
changeset
|
147 | NumberOfProcesses = multiprocessing.cpu_count() |
76ef5f340007
Added functionality to limit the number of processes used for bachground services.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5683
diff
changeset
|
148 | if NumberOfProcesses >= 1: |
76ef5f340007
Added functionality to limit the number of processes used for bachground services.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5683
diff
changeset
|
149 | NumberOfProcesses -= 1 |
76ef5f340007
Added functionality to limit the number of processes used for bachground services.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5683
diff
changeset
|
150 | except NotImplementedError: |
76ef5f340007
Added functionality to limit the number of processes used for bachground services.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5683
diff
changeset
|
151 | NumberOfProcesses = 1 |
76ef5f340007
Added functionality to limit the number of processes used for bachground services.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5683
diff
changeset
|
152 | else: |
76ef5f340007
Added functionality to limit the number of processes used for bachground services.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5683
diff
changeset
|
153 | NumberOfProcesses = maxProcesses |
4231
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
154 | |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
155 | # Create queues |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
156 | taskQueue = multiprocessing.Queue() |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
157 | doneQueue = multiprocessing.Queue() |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
158 | |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
159 | # Submit tasks (initially two time number of processes |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
160 | initialTasks = 2 * NumberOfProcesses |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
161 | for task in argumentsList[:initialTasks]: |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
162 | taskQueue.put(task) |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
163 | |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
164 | # Start worker processes |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
165 | for i in range(NumberOfProcesses): |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
166 | multiprocessing.Process(target=worker, args=(taskQueue, doneQueue))\ |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
167 | .start() |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
168 | |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
169 | # Get and send results |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
170 | endIndex = len(argumentsList) - initialTasks |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
171 | for i in range(len(argumentsList)): |
5672
495b53f37f6c
Corrected an issue in various checker services that caused them to block, if an exception was thrown in a checker class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5616
diff
changeset
|
172 | resultSent = False |
495b53f37f6c
Corrected an issue in various checker services that caused them to block, if an exception was thrown in a checker class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5616
diff
changeset
|
173 | wasCancelled = False |
495b53f37f6c
Corrected an issue in various checker services that caused them to block, if an exception was thrown in a checker class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5616
diff
changeset
|
174 | |
495b53f37f6c
Corrected an issue in various checker services that caused them to block, if an exception was thrown in a checker class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5616
diff
changeset
|
175 | while not resultSent: |
495b53f37f6c
Corrected an issue in various checker services that caused them to block, if an exception was thrown in a checker class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5616
diff
changeset
|
176 | try: |
495b53f37f6c
Corrected an issue in various checker services that caused them to block, if an exception was thrown in a checker class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5616
diff
changeset
|
177 | # get result (waiting max. 3 seconds and send it to frontend |
495b53f37f6c
Corrected an issue in various checker services that caused them to block, if an exception was thrown in a checker class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5616
diff
changeset
|
178 | filename, result = doneQueue.get() |
495b53f37f6c
Corrected an issue in various checker services that caused them to block, if an exception was thrown in a checker class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5616
diff
changeset
|
179 | send(fx, filename, result) |
495b53f37f6c
Corrected an issue in various checker services that caused them to block, if an exception was thrown in a checker class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5616
diff
changeset
|
180 | resultSent = True |
495b53f37f6c
Corrected an issue in various checker services that caused them to block, if an exception was thrown in a checker class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5616
diff
changeset
|
181 | except queue.Empty: |
495b53f37f6c
Corrected an issue in various checker services that caused them to block, if an exception was thrown in a checker class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5616
diff
changeset
|
182 | # ignore empty queue, just carry on |
495b53f37f6c
Corrected an issue in various checker services that caused them to block, if an exception was thrown in a checker class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5616
diff
changeset
|
183 | if cancelled(): |
495b53f37f6c
Corrected an issue in various checker services that caused them to block, if an exception was thrown in a checker class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5616
diff
changeset
|
184 | wasCancelled = True |
495b53f37f6c
Corrected an issue in various checker services that caused them to block, if an exception was thrown in a checker class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5616
diff
changeset
|
185 | break |
495b53f37f6c
Corrected an issue in various checker services that caused them to block, if an exception was thrown in a checker class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5616
diff
changeset
|
186 | |
495b53f37f6c
Corrected an issue in various checker services that caused them to block, if an exception was thrown in a checker class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5616
diff
changeset
|
187 | if wasCancelled or cancelled(): |
4231
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
188 | # just exit the loop ignoring the results of queued tasks |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
189 | break |
5672
495b53f37f6c
Corrected an issue in various checker services that caused them to block, if an exception was thrown in a checker class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5616
diff
changeset
|
190 | |
4231
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
191 | if i < endIndex: |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
192 | taskQueue.put(argumentsList[i + initialTasks]) |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
193 | |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
194 | # Tell child processes to stop |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
195 | for i in range(NumberOfProcesses): |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
196 | taskQueue.put('STOP') |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
197 | |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
198 | |
5588
6ba512d9f46a
Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5586
diff
changeset
|
199 | def worker(inputQueue, outputQueue): |
4231
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
200 | """ |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
201 | Module function acting as the parallel worker for the style check. |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
202 | |
5588
6ba512d9f46a
Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5586
diff
changeset
|
203 | @param inputQueue input queue (multiprocessing.Queue) |
6ba512d9f46a
Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5586
diff
changeset
|
204 | @param outputQueue output queue (multiprocessing.Queue) |
4231
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
205 | """ |
5588
6ba512d9f46a
Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5586
diff
changeset
|
206 | for filename, args in iter(inputQueue.get, 'STOP'): |
4231
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
207 | source, checkFlakes, ignoreStarImportWarnings = args |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
208 | result = __syntaxAndPyflakesCheck(filename, source, checkFlakes, |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
209 | ignoreStarImportWarnings) |
5588
6ba512d9f46a
Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5586
diff
changeset
|
210 | outputQueue.put((filename, result)) |
4231
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
211 | |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
212 | |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
213 | def __syntaxAndPyflakesCheck(filename, codestring, checkFlakes=True, |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
214 | ignoreStarImportWarnings=False): |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
215 | """ |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
216 | Function to compile one Python source file to Python bytecode |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
217 | and to perform a pyflakes check. |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
218 | |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
219 | @param filename source filename (string) |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
220 | @param codestring string containing the code to compile (string) |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
221 | @keyparam checkFlakes flag indicating to do a pyflakes check (boolean) |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
222 | @keyparam ignoreStarImportWarnings flag indicating to |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
223 | ignore 'star import' warnings (boolean) |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
224 | @return dictionary with the keys 'error' and 'warnings' which |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
225 | hold a list containing details about the error/ warnings |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
226 | (file name, line number, column, codestring (only at syntax |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
227 | errors), the message, a list with arguments for the message) |
0b38613388c9
Implemented the batch check mode for the syntax checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4207
diff
changeset
|
228 | """ |
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
229 | try: |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
230 | import builtins |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
231 | except ImportError: |
3515
1b8381afe38f
Merge with default branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3456
diff
changeset
|
232 | import __builtin__ as builtins # __IGNORE_WARNING__ |
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
233 | |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
234 | try: |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
235 | if sys.version_info[0] == 2: |
3159
02cb2adb4868
First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3065
diff
changeset
|
236 | file_enc = filename.encode(sys.getfilesystemencoding()) |
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
237 | else: |
3159
02cb2adb4868
First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3065
diff
changeset
|
238 | file_enc = filename |
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
239 | |
3412
9364dab2d472
Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3228
diff
changeset
|
240 | # It also encode the code back to avoid 'Encoding declaration in |
3159
02cb2adb4868
First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3065
diff
changeset
|
241 | # unicode string' exception on Python2 |
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
242 | codestring = normalizeCode(codestring) |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
243 | |
3635
fc024806236d
Extended the syntax checker to check for VCS conflict markers left over from failed merges.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3630
diff
changeset
|
244 | # Check for VCS conflict markers |
6107
78dabf542c6b
Extended the check for VCS conflict markers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
245 | for conflictMarkerRe in VcsConflictMarkerRegExpList: |
78dabf542c6b
Extended the check for VCS conflict markers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
246 | conflict = conflictMarkerRe.search(codestring) |
78dabf542c6b
Extended the check for VCS conflict markers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
247 | if conflict is not None: |
78dabf542c6b
Extended the check for VCS conflict markers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
248 | start, i = conflict.span() |
78dabf542c6b
Extended the check for VCS conflict markers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
249 | lineindex = 1 + codestring.count("\n", 0, start) |
78dabf542c6b
Extended the check for VCS conflict markers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
250 | return [{'error': |
78dabf542c6b
Extended the check for VCS conflict markers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
251 | (file_enc, lineindex, 0, "", |
78dabf542c6b
Extended the check for VCS conflict markers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
252 | "VCS conflict marker found") |
78dabf542c6b
Extended the check for VCS conflict markers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
253 | }] |
3630
e32c3cec5d7e
Added a TODO: in the syntax checker to check for common VCS conflict markers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3544
diff
changeset
|
254 | |
3159
02cb2adb4868
First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3065
diff
changeset
|
255 | if filename.endswith('.ptl'): |
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
256 | try: |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
257 | import quixote.ptl_compile |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
258 | except ImportError: |
3412
9364dab2d472
Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3228
diff
changeset
|
259 | return [{'error': (filename, 0, 0, '', |
9364dab2d472
Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3228
diff
changeset
|
260 | 'Quixote plugin not found.')}] |
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
261 | template = quixote.ptl_compile.Template(codestring, file_enc) |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
262 | template.compile() |
3412
9364dab2d472
Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3228
diff
changeset
|
263 | else: |
3525
66f4b8646622
Reintegrated the js syntax checker and therefore improved the background service a little.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3515
diff
changeset
|
264 | module = builtins.compile( |
66f4b8646622
Reintegrated the js syntax checker and therefore improved the background service a little.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3515
diff
changeset
|
265 | codestring, file_enc, 'exec', ast.PyCF_ONLY_AST) |
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
266 | except SyntaxError as detail: |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
267 | index = 0 |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
268 | code = "" |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
269 | error = "" |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
270 | lines = traceback.format_exception_only(SyntaxError, detail) |
3159
02cb2adb4868
First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3065
diff
changeset
|
271 | if sys.version_info[0] == 2: |
02cb2adb4868
First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3065
diff
changeset
|
272 | lines = [x.decode(sys.getfilesystemencoding()) for x in lines] |
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
273 | match = re.match('\s*File "(.+)", line (\d+)', |
4385
599681bf149a
Source files now executable even with unicodes in path or filename.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4236
diff
changeset
|
274 | lines[0].replace('<string>', filename)) |
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
275 | if match is not None: |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
276 | fn, line = match.group(1, 2) |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
277 | if lines[1].startswith('SyntaxError:'): |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
278 | error = re.match('SyntaxError: (.+)', lines[1]).group(1) |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
279 | else: |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
280 | code = re.match('(.+)', lines[1]).group(1) |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
281 | for seLine in lines[2:]: |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
282 | if seLine.startswith('SyntaxError:'): |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
283 | error = re.match('SyntaxError: (.+)', seLine).group(1) |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
284 | elif seLine.rstrip().endswith('^'): |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
285 | index = len(seLine.rstrip()) - 4 |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
286 | else: |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
287 | fn = detail.filename |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
288 | line = detail.lineno or 1 |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
289 | error = detail.msg |
3412
9364dab2d472
Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3228
diff
changeset
|
290 | return [{'error': (fn, int(line), index, code.strip(), error)}] |
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
291 | except ValueError as detail: |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
292 | try: |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
293 | fn = detail.filename |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
294 | line = detail.lineno |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
295 | error = detail.msg |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
296 | except AttributeError: |
3159
02cb2adb4868
First implementation for the BackgroundService.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3065
diff
changeset
|
297 | fn = filename |
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
298 | line = 1 |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
299 | error = str(detail) |
3412
9364dab2d472
Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3228
diff
changeset
|
300 | return [{'error': (fn, line, 0, "", error)}] |
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
301 | except Exception as detail: |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
302 | try: |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
303 | fn = detail.filename |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
304 | line = detail.lineno |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
305 | error = detail.msg |
3412
9364dab2d472
Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3228
diff
changeset
|
306 | return [{'error': (fn, line, 0, "", error)}] |
5616
adcffadf4962
Reworked some __IGNORE_WARNING__ comments to be more specific.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5588
diff
changeset
|
307 | except Exception: |
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
308 | pass |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
309 | |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
310 | # pyflakes |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
311 | if not checkFlakes: |
3412
9364dab2d472
Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3228
diff
changeset
|
312 | return [{}] |
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
313 | |
3412
9364dab2d472
Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3228
diff
changeset
|
314 | results = [] |
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
315 | lines = codestring.splitlines() |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
316 | try: |
3544
431c842fd09a
updated pyflakes to version 0.8.1 (Python 3.4.0 compatible)
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3525
diff
changeset
|
317 | warnings = Checker(module, filename, withDoctest=True) |
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
318 | warnings.messages.sort(key=lambda a: a.lineno) |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
319 | for warning in warnings.messages: |
5363
cbe61c2f9772
Extended the code of the flakes checker plug-in to really ignore the * imports warnings, if configured that way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
320 | if ignoreStarImportWarnings and ( |
cbe61c2f9772
Extended the code of the flakes checker plug-in to really ignore the * imports warnings, if configured that way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
321 | isinstance(warning, ImportStarUsed) or |
cbe61c2f9772
Extended the code of the flakes checker plug-in to really ignore the * imports warnings, if configured that way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
322 | isinstance(warning, ImportStarUsage) |
cbe61c2f9772
Extended the code of the flakes checker plug-in to really ignore the * imports warnings, if configured that way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4631
diff
changeset
|
323 | ): |
3065
070b35dde35e
Fixed a bunch of indentation issues.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
2571
diff
changeset
|
324 | continue |
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
325 | |
3177
5af61402d74d
Update pyflakes to 0.7.3
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3173
diff
changeset
|
326 | _fn, lineno, col, message, msg_args = warning.getMessageData() |
5586
0e5421d679e7
Added capability to place line flags (e.g. __IGNORE...) on the line following the one to be ignored.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
327 | lineFlags = extractLineFlags(lines[lineno - 1].strip()) |
0e5421d679e7
Added capability to place line flags (e.g. __IGNORE...) on the line following the one to be ignored.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
328 | try: |
0e5421d679e7
Added capability to place line flags (e.g. __IGNORE...) on the line following the one to be ignored.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
329 | lineFlags += extractLineFlags(lines[lineno].strip(), |
0e5421d679e7
Added capability to place line flags (e.g. __IGNORE...) on the line following the one to be ignored.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
330 | flagsLine=True) |
0e5421d679e7
Added capability to place line flags (e.g. __IGNORE...) on the line following the one to be ignored.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
331 | except IndexError: |
0e5421d679e7
Added capability to place line flags (e.g. __IGNORE...) on the line following the one to be ignored.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
332 | pass |
0e5421d679e7
Added capability to place line flags (e.g. __IGNORE...) on the line following the one to be ignored.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5389
diff
changeset
|
333 | if "__IGNORE_WARNING__" not in lineFlags: |
3412
9364dab2d472
Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3228
diff
changeset
|
334 | results.append((_fn, lineno, col, "", message, msg_args)) |
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
335 | except SyntaxError as err: |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
336 | if err.text.strip(): |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
337 | msg = err.text.strip() |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
338 | else: |
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
339 | msg = err.msg |
3412
9364dab2d472
Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3228
diff
changeset
|
340 | results.append((filename, err.lineno, 0, "FLAKES_ERROR", msg, [])) |
2571
e6bb19eb87ea
Fixes for autocodecheck with pyflakes and update of py2flakes to 0.6.1.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff
changeset
|
341 | |
3412
9364dab2d472
Plug-in docu updated, now the return values of the syntax checker is a dictionary
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3228
diff
changeset
|
342 | return [{'warnings': results}] |
4555
861e1741985c
Adjustments to future imports for Python 2 compatibility.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4543
diff
changeset
|
343 | |
861e1741985c
Adjustments to future imports for Python 2 compatibility.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4543
diff
changeset
|
344 | # |
861e1741985c
Adjustments to future imports for Python 2 compatibility.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4543
diff
changeset
|
345 | # eflag: noqa = M702 |