RadonMetrics/RawMetricsDialog.py

changeset 55
755bc8e1485a
parent 53
4a179abb79e6
child 60
cd2dd96c3c12
equal deleted inserted replaced
54:f7a462d6ec26 55:755bc8e1485a
80 "<tr><td><b>LOC</b></td>" 80 "<tr><td><b>LOC</b></td>"
81 "<td>Lines of code (LOC = SLOC + Empty)</td></tr>" 81 "<td>Lines of code (LOC = SLOC + Empty)</td></tr>"
82 "<tr><td><b>SLOC</b></td><td>Source lines of code</td></tr>" 82 "<tr><td><b>SLOC</b></td><td>Source lines of code</td></tr>"
83 "<tr><td><b>LLOC</b></td><td>Logical lines of code</td></tr>" 83 "<tr><td><b>LLOC</b></td><td>Logical lines of code</td></tr>"
84 "<tr><td><b>Comments</b></td><td>Comment lines</td></tr>" 84 "<tr><td><b>Comments</b></td><td>Comment lines</td></tr>"
85 "<tr><td><b>Empty&nbsp;Comments</b></td><td>Comment lines not"
86 " containing code</td></tr>"
85 "<tr><td><b>Multi</b></td>" 87 "<tr><td><b>Multi</b></td>"
86 "<td>Lines in multi line strings</td></tr>" 88 "<td>Lines in multi line strings</td></tr>"
87 "<tr><td><b>Empty</b></td><td>Blank lines</td></tr>" 89 "<tr><td><b>Empty</b></td><td>Blank lines</td></tr>"
88 "<tr><td colspan=2><b>Comment Statistics:</b></td</tr>" 90 "<tr><td colspan=2><b>Comment Statistics:</b></td</tr>"
89 "<tr><td><b>C % L</b></td><td>Comments to lines ratio</td></tr>" 91 "<tr><td><b>C % L</b></td><td>Comments to lines ratio</td></tr>"
180 182
181 @param fn file or list of files or directory to show 183 @param fn file or list of files or directory to show
182 the code metrics for 184 the code metrics for
183 @type str or list of str 185 @type str or list of str
184 """ 186 """
187 self.cancelled = False
185 self.__errorItem = None 188 self.__errorItem = None
186 self.resultList.clear() 189 self.resultList.clear()
187 self.summaryList.clear() 190 self.summaryList.clear()
188 self.cancelled = False
189 QApplication.processEvents() 191 QApplication.processEvents()
190 192
191 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) 193 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False)
192 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(True) 194 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(True)
193 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) 195 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True)
209 for f in self.files[:]: 211 for f in self.files[:]:
210 if not os.path.exists(f): 212 if not os.path.exists(f):
211 self.files.remove(f) 213 self.files.remove(f)
212 214
213 self.__summary = {"files": 0} 215 self.__summary = {"files": 0}
214 for key in ['loc', 'sloc', 'lloc', 'comments', 'multi', 'blank']: 216 for key in ['loc', 'lloc', 'sloc', 'comments', 'multi',
217 'single_comments', 'blank']:
215 self.__summary[key] = 0 218 self.__summary[key] = 0
216 219
217 if len(self.files) > 0: 220 if len(self.files) > 0:
218 # disable updates of the list for speed 221 # disable updates of the list for speed
219 self.resultList.setUpdatesEnabled(False) 222 self.resultList.setUpdatesEnabled(False)
373 @type dict 376 @type dict
374 @return list of values suitable for display 377 @return list of values suitable for display
375 @rtype list of str 378 @rtype list of str
376 """ 379 """
377 v = [] 380 v = []
378 for key in ['loc', 'sloc', 'lloc', 'comments', 'multi', 'blank']: 381 for key in ['loc', 'sloc', 'lloc', 'comments', 'multi',
379 val = result.get(key, 0) 382 'single_comments', 'blank']:
380 if val: 383 val = result.get(key, -1)
384 if val >= 0:
381 v.append(self.__locale.toString(val)) 385 v.append(self.__locale.toString(val))
382 else: 386 else:
383 v.append('') 387 v.append('')
384 self.__summary[key] += int(val) 388 self.__summary[key] += int(val)
385 self.__summary["files"] += 1 389 self.__summary["files"] += 1
429 self.__createSummaryItem( 433 self.__createSummaryItem(
430 self.tr("LLOC"), self.__locale.toString(self.__summary["lloc"])) 434 self.tr("LLOC"), self.__locale.toString(self.__summary["lloc"]))
431 self.__createSummaryItem( 435 self.__createSummaryItem(
432 self.tr("Comment Lines"), 436 self.tr("Comment Lines"),
433 self.__locale.toString(self.__summary["comments"])) 437 self.__locale.toString(self.__summary["comments"]))
438 self.__createSummaryItem(
439 self.tr("Empty Comments"),
440 self.__locale.toString(self.__summary["single_comments"]))
434 self.__createSummaryItem( 441 self.__createSummaryItem(
435 self.tr("Multiline Strings"), 442 self.tr("Multiline Strings"),
436 self.__locale.toString(self.__summary["multi"])) 443 self.__locale.toString(self.__summary["multi"]))
437 self.__createSummaryItem( 444 self.__createSummaryItem(
438 self.tr("Empty Lines"), 445 self.tr("Empty Lines"),

eric ide

mercurial