def _report_external_dependencies(self, sect, _, _dummy): """return a verbatim layout for displaying dependencies""" dep_info = _make_tree_defs(self._external_dependencies_info().items()) if not dep_info: raise EmptyReportError() tree_str = _repr_tree_defs(dep_info) sect.append(VerbatimText(tree_str))
def report_raw_stats(sect, stats, _): """calculate percentage of code / doc / comment / empty""" total_lines = stats["total_lines"] if not total_lines: raise EmptyReportError() sect.description = "%s lines have been analyzed" % total_lines lines = ("type", "number", "%", "previous", "difference") for node_type in ("code", "docstring", "comment", "empty"): key = node_type + "_lines" total = stats[key] percent = float(total * 100) / total_lines lines += (node_type, str(total), "%.2f" % percent, "NC", "NC") sect.append(Table(children=lines, cols=5, rheaders=1))
def _report_dependencies_graph(self, sect, _, _dummy): """write dependencies as a dot (graphviz) file""" dep_info = self.stats['dependencies'] if not dep_info or not (self.config.import_graph or self.config.ext_import_graph or self.config.int_import_graph): raise EmptyReportError() filename = self.config.import_graph if filename: _make_graph(filename, dep_info, sect, '') filename = self.config.ext_import_graph if filename: _make_graph(filename, self._external_dependencies_info(), sect, 'external ') filename = self.config.int_import_graph if filename: _make_graph(filename, self._internal_dependencies_info(), sect, 'internal ')
def _report_dependencies_graph(self, sect, _, _dummy): """Write dependencies as a dot (graphviz) file.""" dep_info = self.linter.stats.dependencies if not dep_info or not (self.linter.namespace.import_graph or self.linter.namespace.ext_import_graph or self.linter.namespace.int_import_graph): raise EmptyReportError() filename = self.linter.namespace.import_graph if filename: _make_graph(filename, dep_info, sect, "") filename = self.linter.namespace.ext_import_graph if filename: _make_graph(filename, self._external_dependencies_info(), sect, "external ") filename = self.linter.namespace.int_import_graph if filename: _make_graph(filename, self._internal_dependencies_info(), sect, "internal ")
def report_raw_stats(sect, stats, old_stats): """calculate percentage of code / doc / comment / empty """ total_lines = stats['total_lines'] if not total_lines: raise EmptyReportError() sect.description = '%s lines have been analyzed' % total_lines lines = ('type', 'number', '%', 'previous', 'difference') for node_type in ('code', 'docstring', 'comment', 'empty'): key = node_type + '_lines' total = stats[key] percent = float(total * 100) / total_lines old = old_stats.get(key, None) if old is not None: diff_str = diff_string(old, total) else: old, diff_str = 'NC', 'NC' lines += (node_type, str(total), '%.2f' % percent, str(old), diff_str) sect.append(Table(children=lines, cols=5, rheaders=1))
def report_raw_stats( sect, stats: CheckerStats, old_stats: CheckerStats, ): """calculate percentage of code / doc / comment / empty""" total_lines: int = stats["total_lines"] # type: ignore if not total_lines: raise EmptyReportError() sect.description = f"{total_lines} lines have been analyzed" lines = ["type", "number", "%", "previous", "difference"] for node_type in ("code", "docstring", "comment", "empty"): key = node_type + "_lines" total: int = stats[key] # type: ignore percent = float(total * 100) / total_lines old: Optional[Union[int, str]] = old_stats.get(key, None) # type: ignore if old is not None: diff_str = diff_string(old, total) else: old, diff_str = "NC", "NC" lines += [node_type, str(total), f"{percent:.2f}", str(old), diff_str] sect.append(Table(children=lines, cols=5, rheaders=1))