[![PyPI](https://img.shields.io/pypi/v/pygount)](https://pypi.org/project/pygount/)
[![Python Versions](https://img.shields.io/pypi/pyversions/pygount.svg)](https://www.python.org/downloads/)
[![Build Status](https://github.com/roskakori/pygount/actions/workflows/build.yml/badge.svg)](https://github.com/roskakori/pygount/actions/workflows/build.yml)
[![Test Coverage](https://img.shields.io/coveralls/github/roskakori/pygount)](https://coveralls.io/r/roskakori/pygount?branch=master)
[![Black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![License](https://img.shields.io/github/license/roskakori/pygount)](https://opensource.org/licenses/BSD-3-Clause)
# 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](https://www.dwheeler.com/sloccount/) and
[cloc](https://github.com/AlDanial/cloc) but uses the
[pygments](https://pygments.org/)
package to analyze the source code and consequently can analyze any
[programming language supported by pygments](https://pygments.org/languages/).
The name is a combination of pygments and count.
Pygount is open source and distributed under the
[BSD license](https://opensource.org/licenses/BSD-3-Clause). The source
code is available from https://github.com/roskakori/pygount.
## Quickstart
For installation run
```bash
$ pip install pygount
```
To get a list of line counts for a projects stored in a certain folder run for
example:
```bash
$ pygount ~/projects/example
```
To limit the analysis to certain file types identified by their suffix:
```bash
$ pygount --suffix=cfg,py,yml ~/projects/example
```
To get a summary of each programming language with sum counts and percentage:
```bash
$ pygount --format=summary ~/projects/example
```
To analyze a remote git repository directly without having to clone it first:
```bash
$ pygount --format=summary https://github.com/roskakori/pygount.git
```
You can pass a specific revision at the end of the remote URL:
```bash
$ 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](https://wiki.jenkins-ci.org/display/JENKINS/SLOCCount+Plugin)
for the [Jenkins](https://jenkins.io/) 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:
```bash
$ pygount --format=cloc-xml --out=cloc.xml ~/projects/example
```
To get a short description of all available command line options use:
```bash
$ pygount --help
```
For more information and examples read the documentation chapter on
[Usage](https://pygount.readthedocs.io/en/latest/usage.html).
## Contributions
To report bugs, visit the
[issue tracker](https://github.com/roskakori/pygount/issues).
In case you want to play with the source code or contribute improvements, see
[CONTRIBUTING](https://pygount.readthedocs.io/en/latest/contributing.html).
## Version history
See [CHANGES](https://pygount.readthedocs.io/en/latest/changes.html).
Raw data
{
"_id": null,
"home_page": "https://github.com/roskakori/pygount",
"name": "pygount",
"maintainer": null,
"docs_url": null,
"requires_python": "<3.13,>=3.8",
"maintainer_email": null,
"keywords": "code analysis, count, SLOC",
"author": "Thomas Aglassinger",
"author_email": "roskakori@users.sourceforge.net",
"download_url": "https://files.pythonhosted.org/packages/9c/95/abdf57358208ade338e07521ac459d7d93df0a0f7f9328e611400f05df0f/pygount-1.7.0.tar.gz",
"platform": null,
"description": "[![PyPI](https://img.shields.io/pypi/v/pygount)](https://pypi.org/project/pygount/)\n[![Python Versions](https://img.shields.io/pypi/pyversions/pygount.svg)](https://www.python.org/downloads/)\n[![Build Status](https://github.com/roskakori/pygount/actions/workflows/build.yml/badge.svg)](https://github.com/roskakori/pygount/actions/workflows/build.yml)\n[![Test Coverage](https://img.shields.io/coveralls/github/roskakori/pygount)](https://coveralls.io/r/roskakori/pygount?branch=master)\n[![Black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n[![License](https://img.shields.io/github/license/roskakori/pygount)](https://opensource.org/licenses/BSD-3-Clause)\n\n# pygount\n\nPygount is a command line tool to scan folders for source code files and\ncount the number of source code lines in it. It is similar to tools like\n[sloccount](https://www.dwheeler.com/sloccount/) and\n[cloc](https://github.com/AlDanial/cloc) but uses the\n[pygments](https://pygments.org/)\npackage to analyze the source code and consequently can analyze any\n[programming language supported by pygments](https://pygments.org/languages/).\n\nThe name is a combination of pygments and count.\n\nPygount is open source and distributed under the\n[BSD license](https://opensource.org/licenses/BSD-3-Clause). The source\ncode is available from https://github.com/roskakori/pygount.\n\n## Quickstart\n\nFor installation run\n\n```bash\n$ pip install pygount\n```\n\nTo get a list of line counts for a projects stored in a certain folder run for\nexample:\n\n```bash\n$ pygount ~/projects/example\n```\n\nTo limit the analysis to certain file types identified by their suffix:\n\n```bash\n$ pygount --suffix=cfg,py,yml ~/projects/example\n```\n\nTo get a summary of each programming language with sum counts and percentage:\n\n```bash\n$ pygount --format=summary ~/projects/example\n```\n\nTo analyze a remote git repository directly without having to clone it first:\n\n```bash\n$ pygount --format=summary https://github.com/roskakori/pygount.git\n```\n\nYou can pass a specific revision at the end of the remote URL:\n\n```bash\n$ pygount --format=summary https://github.com/roskakori/pygount.git/v1.5.1\n```\n\nThis example results in the following summary output:\n\n```\n\u250f\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2533\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2533\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2533\u2501\u2501\u2501\u2501\u2501\u2501\u2533\u2501\u2501\u2501\u2501\u2501\u2501\u2533\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2533\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n\u2503 Language \u2503 Files \u2503 % \u2503 Code \u2503 % \u2503 Comment \u2503 % \u2503\n\u2521\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2547\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2547\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2547\u2501\u2501\u2501\u2501\u2501\u2501\u2547\u2501\u2501\u2501\u2501\u2501\u2501\u2547\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2547\u2501\u2501\u2501\u2501\u2501\u2501\u2529\n\u2502 Python \u2502 18 \u2502 47.4 \u2502 2132 \u2502 63.6 \u2502 418 \u2502 12.5 \u2502\n\u2502 TOML \u2502 2 \u2502 5.3 \u2502 1204 \u2502 82.7 \u2502 1 \u2502 0.1 \u2502\n\u2502 reStructuredText \u2502 9 \u2502 23.7 \u2502 566 \u2502 64.8 \u2502 1 \u2502 0.1 \u2502\n\u2502 Markdown \u2502 3 \u2502 7.9 \u2502 53 \u2502 49.1 \u2502 0 \u2502 0.0 \u2502\n\u2502 Batchfile \u2502 1 \u2502 2.6 \u2502 24 \u2502 68.6 \u2502 1 \u2502 2.9 \u2502\n\u2502 Text only \u2502 2 \u2502 5.3 \u2502 24 \u2502 82.8 \u2502 0 \u2502 0.0 \u2502\n\u2502 Bash \u2502 2 \u2502 5.3 \u2502 12 \u2502 80.0 \u2502 3 \u2502 20.0 \u2502\n\u2502 Makefile \u2502 1 \u2502 2.6 \u2502 9 \u2502 45.0 \u2502 7 \u2502 35.0 \u2502\n\u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n\u2502 Sum \u2502 38 \u2502 100.0 \u2502 4024 \u2502 68.4 \u2502 431 \u2502 7.3 \u2502\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n```\n\nPlenty of tools can post process SLOC information, for example the\n[SLOCCount plug-in](https://wiki.jenkins-ci.org/display/JENKINS/SLOCCount+Plugin)\nfor the [Jenkins](https://jenkins.io/) continuous integration server.\n\nA popular format for such tools is the XML format used by cloc, which pygount\nalso supports and can store in an output file:\n\n```bash\n$ pygount --format=cloc-xml --out=cloc.xml ~/projects/example\n```\n\nTo get a short description of all available command line options use:\n\n```bash\n$ pygount --help\n```\n\nFor more information and examples read the documentation chapter on\n[Usage](https://pygount.readthedocs.io/en/latest/usage.html).\n\n## Contributions\n\nTo report bugs, visit the\n[issue tracker](https://github.com/roskakori/pygount/issues).\n\nIn case you want to play with the source code or contribute improvements, see\n[CONTRIBUTING](https://pygount.readthedocs.io/en/latest/contributing.html).\n\n## Version history\n\nSee [CHANGES](https://pygount.readthedocs.io/en/latest/changes.html).\n",
"bugtrack_url": null,
"license": "BSD",
"summary": "count source lines of code (SLOC) using pygments",
"version": "1.7.0",
"project_urls": {
"Changes": "https://pygount.readthedocs.io/en/latest/changes.html",
"Documentation": "https://pygount.readthedocs.io",
"Homepage": "https://github.com/roskakori/pygount",
"Issue Tracker": "https://github.com/roskakori/pygount/issues",
"Repository": "https://github.com/roskakori/pygount.git"
},
"split_keywords": [
"code analysis",
" count",
" sloc"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "9ca1376610f72564a0a2a1685f1961672992a224c298b53fc83e83b6cd2a16d9",
"md5": "eef3b0ba604b410096618f81507c4924",
"sha256": "acbb97aa5e9b2c8b63f4bb32d4c2155c59053092edebba4670ada551d86d377d"
},
"downloads": -1,
"filename": "pygount-1.7.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "eef3b0ba604b410096618f81507c4924",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<3.13,>=3.8",
"size": 28641,
"upload_time": "2024-05-12T22:59:06",
"upload_time_iso_8601": "2024-05-12T22:59:06.176501Z",
"url": "https://files.pythonhosted.org/packages/9c/a1/376610f72564a0a2a1685f1961672992a224c298b53fc83e83b6cd2a16d9/pygount-1.7.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "9c95abdf57358208ade338e07521ac459d7d93df0a0f7f9328e611400f05df0f",
"md5": "2f0ff1d174750efec61f06bf30ce2482",
"sha256": "b2767fe9533f8f0e987f9b4d317fe03a2a937dc3f93f8f319ecaf95b4b4eb07e"
},
"downloads": -1,
"filename": "pygount-1.7.0.tar.gz",
"has_sig": false,
"md5_digest": "2f0ff1d174750efec61f06bf30ce2482",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<3.13,>=3.8",
"size": 26704,
"upload_time": "2024-05-12T22:59:08",
"upload_time_iso_8601": "2024-05-12T22:59:08.155467Z",
"url": "https://files.pythonhosted.org/packages/9c/95/abdf57358208ade338e07521ac459d7d93df0a0f7f9328e611400f05df0f/pygount-1.7.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-05-12 22:59:08",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "roskakori",
"github_project": "pygount",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "pygount"
}