Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheckerDialog.py

changeset 795
917f1945355c
parent 794
e338e1e8f3ca
child 802
e8882d16384c
equal deleted inserted replaced
794:e338e1e8f3ca 795:917f1945355c
139 files.extend(Utilities.direntries(fn, 1, '*{0}'.format(ext), 0)) 139 files.extend(Utilities.direntries(fn, 1, '*{0}'.format(ext), 0))
140 else: 140 else:
141 files = [fn] 141 files = [fn]
142 files = [f for f in files \ 142 files = [f for f in files \
143 if f.endswith(tuple(Preferences.getPython("Python3Extensions")))] 143 if f.endswith(tuple(Preferences.getPython("Python3Extensions")))]
144 py2files = [f for f in files \
145 if f.endswith(tuple(Preferences.getPython("PythonExtensions")))]
144 146
145 if (codestring and len(files) == 1) or \ 147 if (codestring and len(files) == 1) or \
146 (not codestring and len(files) > 0): 148 (codestring and len(py2files) == 1) or \
147 self.checkProgress.setMaximum(len(files)) 149 (not codestring and len(files) + len(py2files) > 0):
150 self.checkProgress.setMaximum(len(files) + len(py2files))
148 QApplication.processEvents() 151 QApplication.processEvents()
149 152
150 ignoreStarImportWarnings = Preferences.getFlakes("IgnoreStarImportWarnings") 153 ignoreStarImportWarnings = Preferences.getFlakes("IgnoreStarImportWarnings")
154
151 # now go through all the files 155 # now go through all the files
152 progress = 0 156 progress = 0
153 for file in files: 157 for file in files + py2files:
154 self.checkProgress.setValue(progress) 158 self.checkProgress.setValue(progress)
155 QApplication.processEvents() 159 QApplication.processEvents()
156 self.__resort() 160 self.__resort()
157 161
158 if self.cancelled: 162 if self.cancelled:
173 "Error: {0}".format(str(msg)).rstrip()[1:-1], "") 177 "Error: {0}".format(str(msg)).rstrip()[1:-1], "")
174 progress += 1 178 progress += 1
175 continue 179 continue
176 180
177 flags = Utilities.extractFlags(source) 181 flags = Utilities.extractFlags(source)
178 if "FileType" in flags and flags["FileType"] != "Python3": 182 if ("FileType" in flags and flags["FileType"] != "Python3") or \
179 # skip non Python 3 files 183 file in py2files:
180 progress += 1 184 isPy3 = False
181 continue 185 nok, fname, line, code, error = Utilities.py2compile(file)
182 186 else:
183 nok, fname, line, code, error = Utilities.compile(file, source) 187 isPy3 = True
188 nok, fname, line, code, error = Utilities.compile(file, source)
184 if nok: 189 if nok:
185 self.noResults = False 190 self.noResults = False
186 self.__createResultItem(fname, line, error, code) 191 self.__createResultItem(fname, line, error, code)
187 else: 192 else:
188 if Preferences.getFlakes("IncludeInSyntaxCheck"): 193 if Preferences.getFlakes("IncludeInSyntaxCheck") and isPy3:
189 try: 194 try:
190 sourceLines = source.splitlines() 195 sourceLines = source.splitlines()
191 warnings = Checker(source, file) 196 warnings = Checker(source, file)
192 warnings.messages.sort(key = lambda a: a.lineno) 197 warnings.messages.sort(key = lambda a: a.lineno)
193 for warning in warnings.messages: 198 for warning in warnings.messages:

eric ide

mercurial