138 @param fn file or list of files or directory to be checked |
141 @param fn file or list of files or directory to be checked |
139 (string or list of strings) |
142 (string or list of strings) |
140 @param codestring string containing the code to be checked (string). |
143 @param codestring string containing the code to be checked (string). |
141 If this is given, fn must be a single file name. |
144 If this is given, fn must be a single file name. |
142 """ |
145 """ |
143 if self.__project is None: |
146 if self.syntaxCheckService is not None: |
144 self.__project = e5App().getObject("Project") |
147 if self.__project is None: |
145 |
148 self.__project = e5App().getObject("Project") |
146 self.cancelled = False |
149 |
147 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) |
150 self.cancelled = False |
148 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(True) |
151 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) |
149 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) |
152 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(True) |
150 self.checkProgress.setVisible(True) |
153 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) |
151 QApplication.processEvents() |
154 self.checkProgress.setVisible(True) |
152 |
|
153 if isinstance(fn, list): |
|
154 self.files = fn |
|
155 elif os.path.isdir(fn): |
|
156 self.files = [] |
|
157 for ext in self.syntaxCheckService.getExtensions(): |
|
158 self.files.extend( |
|
159 Utilities.direntries(fn, True, '*{0}'.format(ext), 0)) |
|
160 else: |
|
161 self.files = [fn] |
|
162 |
|
163 self.__clearErrors(self.files) |
|
164 |
|
165 if codestring or len(self.files) > 0: |
|
166 self.checkProgress.setMaximum(max(1, len(self.files))) |
|
167 self.checkProgress.setVisible(len(self.files) > 1) |
|
168 self.checkProgressLabel.setVisible(len(self.files) > 1) |
|
169 QApplication.processEvents() |
155 QApplication.processEvents() |
170 |
156 |
171 # now go through all the files |
157 if isinstance(fn, list): |
172 self.progress = 0 |
158 self.files = fn |
173 self.check(codestring) |
159 elif os.path.isdir(fn): |
|
160 self.files = [] |
|
161 for ext in self.syntaxCheckService.getExtensions(): |
|
162 self.files.extend( |
|
163 Utilities.direntries(fn, True, '*{0}'.format(ext), 0)) |
|
164 else: |
|
165 self.files = [fn] |
|
166 |
|
167 self.__clearErrors(self.files) |
|
168 |
|
169 if codestring or len(self.files) > 0: |
|
170 self.checkProgress.setMaximum(max(1, len(self.files))) |
|
171 self.checkProgress.setVisible(len(self.files) > 1) |
|
172 self.checkProgressLabel.setVisible(len(self.files) > 1) |
|
173 QApplication.processEvents() |
|
174 |
|
175 # now go through all the files |
|
176 self.progress = 0 |
|
177 self.check(codestring) |
174 |
178 |
175 def check(self, codestring=''): |
179 def check(self, codestring=''): |
176 """ |
180 """ |
177 Public method to start a check for one file. |
181 Public method to start a check for one file. |
178 |
182 |
179 The results are reported to the __processResult slot. |
183 The results are reported to the __processResult slot. |
180 @keyparam codestring optional sourcestring (str) |
184 @keyparam codestring optional sourcestring (str) |
181 """ |
185 """ |
182 if not self.files: |
186 if self.syntaxCheckService is None or not self.files: |
183 self.__finish() |
187 self.__finish() |
184 return |
188 return |
185 |
189 |
186 self.filename = self.files.pop(0) |
190 self.filename = self.files.pop(0) |
187 self.checkProgress.setValue(self.progress) |
191 self.checkProgress.setValue(self.progress) |