PyCodeStats
PyCodeStats is a small Python library for collecting basic statistics from Python files.
Features
- Total lines
- Blank lines
- Comment lines
- Code lines
- Variables
- Functions
- Classes
- Imports
if/elif/elseforloopswhileloopsreturnstatements
Install
pip install codestats-py
Usage
import codestats as cs
stats = cs.analyze("main.py")
print(stats)
Access individual stats
import codestats as cs
stats = cs.analyze("main.py")
print(stats.total_lines)
print(stats.functions)
print(stats.classes)
print(stats.variables)
print(stats.for_loops)
print(stats.while_loops)
Pretty report
import codestats as cs
cs.report("main.py")
Example output
==============================
PYCODESTATS
==============================
Total Lines : 120
Blank Lines : 18
Comment Lines : 9
Code Lines : 102
Variables : 15
Functions : 4
Classes : 2
Imports : 3
If : 6
Elif : 2
Else : 3
For Loops : 5
While Loops : 1
Returns : 7
==============================
API
analyze(file_path)
Returns one CodeStats object containing all counts.
report(file_path)
Prints a formatted report and also returns it as a string.
Planned future versions
- Directory analysis
- JSON export
- CSV export
- CLI
- More metrics
License
MIT
Metadata
Release files for codestats-py 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| codestats_py-1.0.0.tar.gz | 5.9 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| codestats_py-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.7 kB
Release files / codestats_py-1.0.0.tar.gz
| Download URL | codestats_py-1.0.0.tar.gz |
|---|---|
| Size | 5.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1fad44061ed158e7c68996011e5267e13d6e071c853f6ef2e332ad20a307be22
|
|
BLAKE2b-256 checksum How to use checksums |
4c5116113ffb4d3ab024fd2f30a930bbd94f8a87e0b6696a7f2575307a7d06de
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.3
|
Release files / codestats_py-1.0.0-py3-none-any.whl
| Download URL | codestats_py-1.0.0-py3-none-any.whl |
|---|---|
| Size | 6.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
03a05749adbc467236bdef575c1a65102f8321c2138d606f31d38a722cf2ffba
|
|
BLAKE2b-256 checksum How to use checksums |
0409b321de0c7638a4cec70dedeb219d27db7fec5a876c041667f91a881798a4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.3
|
Security for codestats-py 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.