Skip to main content

count source lines of code (SLOC) using pygments

Project description

Python Versions Build Status Test Coverage License

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/exammple

To limit the analysis to certain file types identified by their suffix:

$ pygount --suffix=cfg,py,yml  ~/projects/exammple

To get a summary of each programming language with sum counts and percentage:

$ pygount --format=summary ~/projects/exammple

As an example here is the summary output for pygount's own source code:

    Language      Files    %     Code    %     Comment    %
----------------  -----  ------  ----  ------  -------  ------
Python               19   51.35  1924   72.99      322   86.10
reStructuredText      7   18.92   332   12.59        7    1.87
markdown              3    8.11   327   12.41        1    0.27
Batchfile             1    2.70    24    0.91        1    0.27
YAML                  1    2.70    11    0.42        2    0.53
Makefile              1    2.70     9    0.34        7    1.87
INI                   1    2.70     5    0.19        0    0.00
TOML                  1    2.70     4    0.15        0    0.00
Text                  3    8.11     0    0.00       34    9.09
----------------  -----  ------  ----  ------  -------  ------
Sum total            37          2636              374

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/exammple

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pygount-1.2.4-py3-none-any.whl (25.7 kB view details)

Uploaded Python 3

File details

Details for the file pygount-1.2.4-py3-none-any.whl.

File metadata

  • Download URL: pygount-1.2.4-py3-none-any.whl
  • Upload date:
  • Size: 25.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/49.3.1 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6

File hashes

Hashes for pygount-1.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 8ec56e58cfcb2be8bb54f32f02e7130d33302e2543c8a37b441e606ea3b8a2c5
MD5 b2417fe706764e745184d88af543fb10
BLAKE2b-256 366f29fe06d1afd8ca4dd74cfc36411595e2d75e4acdd5f523e92cf72b7bbc3b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page