Skip to content

cdeil/pyprojectstats

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pyprojectstats

Quick and simple Python project statistics

Build Status

What is this?

This is a command line application (pyprojectstats) and Python package (import pyprojectstats) that gives you a quick overview of a Python project.

tl;dr

To use this, just pip install pyprojectstats (requires Python 3.6 or later), and point it at a project you're interested in:

pip install pyprojectstats
cd /somewhere/someproject
pyprojectstats .

Why?

There are many other similar tools. Why create another one?

There wasn't any that really did what I wanted. E.g. there's many line count tools, but they usually don't allow counting docstring lines separately (some count docstrings as code, some as comments), and they don't allow counting lines of code in Jupyter notebooks. And there's packages to analyse Python code, but getting a summary on how much code, tests, docs, classes, functions, etc. is in a given Python project requires quite some expertise and scripting.

That's what pyprojectstats does for you - it aims to make it quick and simple to get an overview of any Python project.

This can be useful for a project maintainer for your own project, or as a developer trying to evaluate and gauge the size of a new package you encounter.

Also: implementing this is a fun side project, where I get to try out and learn a few things that are new to me: dataclasses, flit, ast

Features

  • Files supported: Python, Cython, Jupyter notebooks, reStructuredText (docs)
  • Count number of files in the project of each type
  • Count lines and breakdown by code, comments, blanks
  • Also more fine-grained break down, especially concerning docstrings
  • Count number of classes, functions, methods
  • Separately count code and test
  • Word and line count for documentation (both rst or ipynb)

Two modes of operation:

  • Command line tool for the most common tasks
  • Flexible Python API to collect, analyse and access results

Currently not planned:

  • Analyse project history (will add example how to script this, but not built-in)
  • Code quality metrics, like function length or complexity

Usage example

Command line tool

Let's see what info we get for black:

$ git clone https://github.com/python/black
$ cd black
$ pyprojectstats black

Use pyprojectstats --help to see all available options.

Python package

To use pyprojectstats as a Python package:

import pyprojectstats
project = pyprojectstats.Project("black")
project.collect()
project.analyse()
project.report()

I plan to add documentation for this project. For now, you'll just have to check the source code and tests if you want to see what's available.

Development

Development of pyprojectstats just started, it's not in a usable state yet.

  • If you have any questions, feel free to contact me (https://christophdeil.com/) via Github, Twitter or Email
  • Issues with bug reports and feature requests welcome!
  • Pull requests welcome!

Other packages

Some other packages and scripts that do similar things.

This is mostly a link collection for myself - I didn't look in detail at most of these yet.

Releases

No releases published

Packages

No packages published

Languages