def _make_graph(filename, dep_info, sect, gtype): """generate a dependencies graph and add some information about it in the report's section """ _dependencies_graph(filename, dep_info) sect.append(Paragraph('%simports graph has been written to %s' % (gtype, filename)))
def report_raw_stats( sect: Section, stats: LinterStats, old_stats: LinterStats | None, ) -> None: """Calculate percentage of code / doc / comment / empty.""" total_lines = stats.code_type_count["total"] sect.insert(0, Paragraph([Text(f"{total_lines} lines have been analyzed\n")])) lines = ["type", "number", "%", "previous", "difference"] for node_type in ("code", "docstring", "comment", "empty"): node_type = cast(Literal["code", "docstring", "comment", "empty"], node_type) total = stats.code_type_count[node_type] percent = float(total * 100) / total_lines if total_lines else None old = old_stats.code_type_count[node_type] if old_stats else None diff_str = diff_string(old, total) if old else None lines += [ node_type, str(total), f"{percent:.2f}" if percent is not None else "NC", str(old) if old else "NC", diff_str if diff_str else "NC", ] sect.append(Table(children=lines, cols=5, rheaders=1))
def _make_graph(filename: str, dep_info: Dict[str, List[str]], sect: VNode, gtype: str): """generate a dependencies graph and add some information about it in the report's section """ outputfile = _dependencies_graph(filename, dep_info) sect.append( Paragraph(f"{gtype}imports graph has been written to {outputfile}"))