Skip to main content

📦 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

Metadata

Release files for extliner 0.0.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for extliner 0.0.10
File Size Uploaded
extliner-0.0.10.tar.gz 14.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for extliner 0.0.10
File Interpreter ABI Platform
extliner-0.0.10-py3-none-any.whl Python 3 none any Details

Total release size: 21.0 kB

Release files / extliner-0.0.10.tar.gz

Download URL extliner-0.0.10.tar.gz
Size 14.0 kB
Tags Source
SHA-256 checksum
How to use checksums
92acc5adf8c014d166ceb7e48e7244ed772b37362b7a20e45bd43f0bae2ada53
BLAKE2b-256 checksum
How to use checksums
3352763d24da3eec1379f45724202d93f218d484c7fc88e227b877a45bbeb0aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.32.5

Release files / extliner-0.0.10-py3-none-any.whl

Download URL extliner-0.0.10-py3-none-any.whl
Size 7.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e1e9f70c829991f32168f26b78f2269681c50d52bfbbf9e8f5596c42fa21f980
BLAKE2b-256 checksum
How to use checksums
b5640dee8130ed95f856694c775f852680b07e69aa0b145bb84ed4b33a97f721
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.32.5

Release history Release notifications | RSS feed

This release

0.0.10 This release

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page