Skip to main content

Add your description here

Project description

Python Loc Counter - PYLOCC

Tests Coverage

pylocc logo

pylocc is a command-line tool for counting lines of code in various programming languages. It helps you get a quick overview of the size and composition of your codebase.

This project draws instiparion from scc and uses the same language.json file.

Features

Please have a look at the documentaiton page for more details.

  • Counts lines of code, comments, and blank lines.
  • Supports a wide range of programming languages.
  • Can process single files or entire directories.
  • Provides both aggregated and per-file reports.
  • Easy to use and configure.

Requirements

  • Python >= 3.10

Installation

From Pypi

 pip install pylocc

 pylocc --help

From Source

  1. Clone the repository:
    git clone https://github.com/your-username/pylocc.git
    
  2. Navigate to the project directory:
    cd pylocc
    
  3. Install the dependencies:
    uv run pylocc
    

Usage

To use pylocc, run the following command:

pylocc [OPTIONS] <file_or_directory>

or

uv run pylocc --help
Usage: pylocc [OPTIONS] FILE

  Run pylocc on the specified file or directory.

Options:
  --by-file      Generate report by file.
  --output FILE  Stores the output report in csv format to the given path
  --help         Show this message and exit.

Options

  • --by-file: Generate a report for each file individually.
  • --output <path>: Save the report to a file.

Examples

  • Count lines of code in a single file:
    pylocc my_file.py
    
  • Count lines of code in a directory and all its subdirectories:
    pylocc my_project/
    
  • Generate a per-file report:
    pylocc --by-file my_project/
    
  • Save the report to a file:
    pylocc --output report.csv my_project/
    

Configuration

pylocc uses a language.json file to define the comment syntax for different languages. You can customize this file to add new languages or modify existing ones.

Each language entry in language.json has the following structure:

{
  "LanguageName": {
    "extensions": ["ext1", "ext2"],
    "line_comment": ["//"],
    "multi_line": [["/*", "*/"]]
  }
}
  • extensions: A list of file extensions for the language.
  • line_comment: A list of strings that represent single-line comments.
  • multi_line: A list of pairs of strings that represent the start and end of multi-line comments.

Contributing

Contributions are welcome! Please feel free to open an issue or submit a pull request.

Project details


Download files

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

Source Distribution

pylocc-1.5.2.tar.gz (25.1 kB view details)

Uploaded Source

Built Distribution

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

pylocc-1.5.2-py3-none-any.whl (26.0 kB view details)

Uploaded Python 3

File details

Details for the file pylocc-1.5.2.tar.gz.

File metadata

  • Download URL: pylocc-1.5.2.tar.gz
  • Upload date:
  • Size: 25.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.3 {"installer":{"name":"uv","version":"0.10.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pylocc-1.5.2.tar.gz
Algorithm Hash digest
SHA256 452901bfd1f989c083c48ce4913caa4352832b96f72a3253243336f079e986b8
MD5 103bf34a1ac8d42e76cacfe6f181de29
BLAKE2b-256 e01c88352a0572251b91470f23e1ae4f72e9fa3375ab3e80f63f0adb74d99e83

See more details on using hashes here.

File details

Details for the file pylocc-1.5.2-py3-none-any.whl.

File metadata

  • Download URL: pylocc-1.5.2-py3-none-any.whl
  • Upload date:
  • Size: 26.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.3 {"installer":{"name":"uv","version":"0.10.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pylocc-1.5.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5ffb7208741b0050ceae04cc083a731c27089c590da8670e15df71c9b76f859e
MD5 a5e07a7a9afb71a953cc4c30d66e285d
BLAKE2b-256 907e354e923fa29ce295bbe56851f002f5c104c45aacc809ee43143e445cfe55

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