Package: reducto
ReductoReductois a command line utility to extract statistical features from yourpythonsource code.Count the number of lines in a project (.py files only)Number of functions/methods.Average function length.Docstring lines.Comment lines.Blank lines.Source files (number of .py files).Source lines (number of lines corresponding to python code, total number of lines minus docstrings, comments and blank lines).For the average package the code should be fast enough. The average time is of 0.5 seconds against
top pypi packages by number of downloads.A simple analysis run top of the 4000 top pypi packages at the following repository:top_pypi_source_code_stats.Development statusInstallationreductois available inPyPI, run from your terminal:$ pip install reductoInstall with extras to print tables viatabulate:$ pip install reducto[tabulate]Currently tested on python 3.8 only.UsageTo start with the default example:$ reducto {source_file_or_directory}The default mode will print the basejsonreport to the command line usingpprint.pprint.Let's see an example running on the reducto source code (for the current version):$reductoreducto{'reducto':{'average_function_length':6,'blank_lines':208,'comment_lines':20,'docstring_lines':803,'lines':1973,'number_of_functions':108,'source_files':7,'source_lines':942}}The formats includejsonas a default, but when installingtabulatedependency,
the formats defined there are available too. For example:$reductoreducto--format="rst"================================================================================packagelinesnumbersourcedocstringcommentblankaveragesourceoflineslineslineslinesfunctionfilesfunctionslength================================================================================reducto19731089428032020867================================================================================Or copying directly the output from executingreducto reducto/ --format "github" --percentageto this README.md:packagelinesnumber_of_functionssource_linesdocstring_linescomment_linesblank_linesaverage_function_lengthsource_filesreducto197310848%41%1%11%67Typing the help command may show the different formats defined currently, but for more
info, thedocumentationmay be more helpful.$reducto--help
usage:reducto[-h][-v][-f{json,simple,plain,grid,fancy_grid,github,pipe,orgtbl,jira,presto,pretty,psql,rst,mediawiki,moinmoin,youtrack,html,unsafehtml,latex,latex_raw,latex_booktabs,latex_longtable,tsv,textile}][--grouped|--ungrouped][-oOUTPUT][-p][target]positionalarguments:targetPathtoexecutetheprograminto.Mustbeeitherapythonpackage(directorycontainingan__init__.py)orapythonsourcefile{SRC.py}optionalarguments:-h,--helpshowthishelpmessageandexit-v,--versionShowtheversionoftheprogram.-f{json,simple,plain,grid,fancy_grid,github,pipe,orgtbl,jira,presto,pretty,psql,rst,mediawiki,moinmoin,youtrack,html,unsafehtml,latex,latex_raw,latex_booktabs,latex_longtable,tsv,textile},--format{json,simple,plain,grid,fancy_grid,github,pipe,orgtbl,jira,presto,pretty,psql,rst,mediawiki,moinmoin,youtrack,html,unsafehtml,latex,latex_raw,latex_booktabs,latex_longtable,tsv,textile}Formatforthereporttype.--groupedReturntheresultsseparatedbysourcefiles,orgroupedforthewholepackage.Onlyusedwhenthetargetpathisapackage.--ungroupedOppositeof--grouped.-oOUTPUT,--outputOUTPUTFullpathofthereporttobegenerated.Ifnotgiven,redirectstostdout.-p,--percentageReportthenumberoflinesaspercentage.DocumentationRead the documentation onReadTheDocs.LicenseMIT License