From 86282cd314430112167a68b7a4590204a6e97cde Mon Sep 17 00:00:00 2001 From: spark Date: Fri, 30 Oct 2026 07:50:28 +0000 Subject: [PATCH] spark: add count_py_files.py - utility to recursively count Python files in directory tree --- wizard-work/spark/count_py_files.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 wizard-work/spark/count_py_files.py diff --git a/wizard-work/spark/count_py_files.py b/wizard-work/spark/count_py_files.py new file mode 100644 index 0000000..023f6f5 --- /dev/null +++ b/wizard-work/spark/count_py_files.py @@ -0,0 +1,12 @@ +#!/usr/bin/env python3 +"""Count Python files in directory tree recursively.""" +import sys +from pathlib import Path + +def count_py_files(directory: str = ".") -> int: + """Count Python files in directory tree.""" + return len(list(Path(directory).rglob("*.py"))) + +if __name__ == "__main__": + target = sys.argv[1] if len(sys.argv) > 1 else "." + print(count_py_files(target)) \ No newline at end of file