count source lines of code (SLOC) using pygments
Project description
pygount
Pygount is a command line tool to scan folders for source code files and count the number of source code lines in it. It is similar to tools like sloccount and cloc but uses the pygments package to analyze the source code and consequently can analyze any programming language supported by pygments.
The name is a combination of pygments and count.
Pygount is open source and distributed under the BSD license. The source code is available from https://github.com/roskakori/pygount.
Quickstart
For installation run
$ pip install pygount
To get a list of line counts for a projects stored in a certain folder run for example:
$ pygount ~/projects/example
To limit the analysis to certain file types identified by their suffix:
$ pygount --suffix=cfg,py,yml ~/projects/example
To get a summary of each programming language with sum counts and percentage:
$ pygount --format=summary ~/projects/example
To analyze a remote git repository directly without having to clone it first:
$ pygount --format=summary https://github.com/roskakori/pygount.git
You can pass a specific revision at the end of the remote URL:
$ pygount --format=summary https://github.com/roskakori/pygount.git/v1.5.1
This example results in the following summary output:
┏━━━━━━━━━━━━━━━━━━┳━━━━━━━┳━━━━━━━┳━━━━━━┳━━━━━━┳━━━━━━━━━┳━━━━━━┓
┃ Language ┃ Files ┃ % ┃ Code ┃ % ┃ Comment ┃ % ┃
┡━━━━━━━━━━━━━━━━━━╇━━━━━━━╇━━━━━━━╇━━━━━━╇━━━━━━╇━━━━━━━━━╇━━━━━━┩
│ Python │ 18 │ 47.4 │ 2132 │ 63.6 │ 418 │ 12.5 │
│ TOML │ 2 │ 5.3 │ 1204 │ 82.7 │ 1 │ 0.1 │
│ reStructuredText │ 9 │ 23.7 │ 566 │ 64.8 │ 1 │ 0.1 │
│ Markdown │ 3 │ 7.9 │ 53 │ 49.1 │ 0 │ 0.0 │
│ Batchfile │ 1 │ 2.6 │ 24 │ 68.6 │ 1 │ 2.9 │
│ Text only │ 2 │ 5.3 │ 24 │ 82.8 │ 0 │ 0.0 │
│ Bash │ 2 │ 5.3 │ 12 │ 80.0 │ 3 │ 20.0 │
│ Makefile │ 1 │ 2.6 │ 9 │ 45.0 │ 7 │ 35.0 │
├──────────────────┼───────┼───────┼──────┼──────┼─────────┼──────┤
│ Sum │ 38 │ 100.0 │ 4024 │ 68.4 │ 431 │ 7.3 │
└──────────────────┴───────┴───────┴──────┴──────┴─────────┴──────┘
Plenty of tools can post process SLOC information, for example the SLOCCount plug-in for the Jenkins continuous integration server.
A popular format for such tools is the XML format used by cloc, which pygount also supports and can store in an output file:
$ pygount --format=cloc-xml --out=cloc.xml ~/projects/example
To get a short description of all available command line options use:
$ pygount --help
For more information and examples read the documentation chapter on Usage.
Contributions
To report bugs, visit the issue tracker.
In case you want to play with the source code or contribute improvements, see CONTRIBUTING.
Version history
See CHANGES.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pygount-1.8.0.tar.gz
.
File metadata
- Download URL: pygount-1.8.0.tar.gz
- Upload date:
- Size: 26.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.12.3 Darwin/23.4.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a1c530a8ff473c99dc7cd24b034f382d60f51efcac3a1d2181642124dbda2173 |
|
MD5 | f1a48da1dd306e69481ad50c9ee09e73 |
|
BLAKE2b-256 | 361a3d888ff0e1bb40602ffe54727311f985e7f8ece6f1b8a3d7564fe98f6852 |
File details
Details for the file pygount-1.8.0-py3-none-any.whl
.
File metadata
- Download URL: pygount-1.8.0-py3-none-any.whl
- Upload date:
- Size: 28.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.12.3 Darwin/23.4.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb4e27ae3709674a91e349f503240ffeaef7efa59d1e026c7e4b2278dd3deb7f |
|
MD5 | fbc0e30e2c4db2e7b24521f232275f80 |
|
BLAKE2b-256 | 31aa5f21aa9c97d141ff893a55731b6791363332a331b3167f39604ace7194b0 |