Skip to main content

A simple command-line tool to count lines in files by extension.

Project description

📦 extliner

extliner is a lightweight Python package that recursively counts lines in files — distinguishing between total lines and non-empty lines — grouped by file extension. It's perfect for analyzing codebases, writing statistics, or cleaning up documentation-heavy directories.


🚀 Features

  • 📂 Recursive directory scanning
  • 🧮 Counts:
    • Total lines (with whitespace)
    • Non-empty lines (ignores blank lines)
  • 🔠 Groups results by file extension (.py, .js, NO_EXT, etc.)
  • 🚫 Support for ignoring specific extensions or folders
  • 📊 Output formats:
    • Pretty CLI table
    • JSON / CSV / Markdown exports
  • 🧩 Clean, extensible class-based design
  • 🧪 Fully tested with unittest
  • 🔧 CLI and Python API support

📥 Installation

Install via pip:

pip install extliner

Or install locally for development:

git clone https://github.com/extliner/extliner.git
cd extliner
pip install -e .

⚙️ CLI Usage

✅ Basic

extliner -d <directory_path>

🔍 Ignoring Extensions

extliner -d ./myproject --ignore .md .log

Ignoring Folders

extliner -d ./myproject --folders .venv __pycache__

🧾 Output Example

+-------------+---------------+------------------+---------+--------------+
| Extension   |   With Spaces |   Without Spaces |   Files | % of Total   |
+=============+===============+==================+=========+==============+
| .py         |           443 |              362 |       7 | 32.15%       |
+-------------+---------------+------------------+---------+--------------+
| no_ext      |           361 |              287 |       8 | 26.20%       |
+-------------+---------------+------------------+---------+--------------+
| .pyc        |           151 |              125 |       3 | 10.96%       |
+-------------+---------------+------------------+---------+--------------+

🧱 Python API

✅ Count Lines Programmatically

from extliner.main import LineCounter
from pathlib import Path

counter = LineCounter(ignore_extensions=[".log", ".json"])
result = counter.count_lines(Path("./your_directory"))

# Output as JSON
print(counter.to_json(result))

# Output as Markdown
print(counter.to_markdown(result))

# Output as CSV
print(counter.to_csv(result))

🛠️ Configuration Options

Flag Description Example Optioal/Required
-d Directory to scan -d ./src Required
--ignore File extensions to ignore --ignore .log .md .json Optional
--folders Folder names to ignore --folders .venv __pycache__ Optional

📂 Supported Formats

Output Method Description
to_json(data) Returns JSON string
to_csv(data) Returns CSV string
to_markdown(data) Returns Markdown table

✅ Testing

To run tests:

python -m unittest discover tests

Or using pytest (if installed):

pytest

📄 License

This project is licensed under the MIT License.


👨‍💻 Author

Made with ❤️ by Deepak Raj

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

extliner-0.0.2.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

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

extliner-0.0.2-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file extliner-0.0.2.tar.gz.

File metadata

  • Download URL: extliner-0.0.2.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for extliner-0.0.2.tar.gz
Algorithm Hash digest
SHA256 8ac6881841036f1d71e9317e3fb3e01c6fb7c588c4074a20cf92956f29386e00
MD5 ea0ab6ef19a7e991475003319d088b89
BLAKE2b-256 9b301e8f485c35a0354759b2768229b1c002c0625d320c0f919b5d86b30c530e

See more details on using hashes here.

File details

Details for the file extliner-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: extliner-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for extliner-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 93004277b6b01391d2fad58bc6fc842d729f38399961999792cb64c4b12ae8d4
MD5 20732e4f8774ec0f50a1d99c9075f8a1
BLAKE2b-256 061b647f4bd603d90108e1b0068cdfdf320217c542613cfd745c07de4edbfefb

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