I have created a new application called lopc
(Lines of Python Code). It is available for install with pip
on PyPI (https://pypi.org/project/lopc/), and the source code is available on GitHub: https://github.com/markkuleinio/lopc
The app really only counts the number of non-empty and non-comment lines of *.py
files in the given directories. These are some features of the code:
- The command arguments are parsed with
argparse
, demonstrating using same option multiple times:-e <dir>
(--exclude-dir
) can be used for excluding several directories, and-v
(--verbose
) can be used to increase verbosity (-vv
) pathlib
is used for path manipulation and file reading- Recursive function calls are used for scanning the full directory tree.
Example run:
markku@devel:~$ lopc devel/lopc -v -e build File: devel/lopc/setup.py (16 lines) File: devel/lopc/lopc/__main__.py (5 lines) File: devel/lopc/lopc/lopc.py (124 lines) File: devel/lopc/lopc/__init__.py (0 lines) devel/lopc Files: 4 Lines: 145 markku@devel:~$