From 29285d9e136ed73ccb1326ba7224d6c0fa903c88 Mon Sep 17 00:00:00 2001 From: bleudev Date: Sun, 9 Jun 2024 23:28:37 +0300 Subject: [PATCH] ufpy 0.1.1 (new function - number_of_files_with_extensions) --- ufpy/__init__.py | 3 ++- ufpy/path_tools.py | 14 ++++++++++++++ upload.bat | 2 -- 3 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 ufpy/path_tools.py diff --git a/ufpy/__init__.py b/ufpy/__init__.py index 324ec5c..f737223 100644 --- a/ufpy/__init__.py +++ b/ufpy/__init__.py @@ -1,7 +1,8 @@ -__version__ = '0.1' +__version__ = '0.1.1' from .cmp import * from .math_op import * +from .path_tools import * from .udict import * from .ustack import * from .utils import * diff --git a/ufpy/path_tools.py b/ufpy/path_tools.py new file mode 100644 index 0000000..d85e839 --- /dev/null +++ b/ufpy/path_tools.py @@ -0,0 +1,14 @@ +__all__ = ( + 'number_of_files_with_extensions', +) + +import os + +def number_of_files_with_extensions(path, extension) -> int: + r = 0 + for p in os.listdir(path): + if os.path.isdir(f'{path}/{p}'): + r += number_of_files_with_extensions(f'{path}/{p}', extension) + elif p.endswith(f'.{extension}'): + r += 1 + return r diff --git a/upload.bat b/upload.bat index f90a080..601b75e 100644 --- a/upload.bat +++ b/upload.bat @@ -8,5 +8,3 @@ py -3.12 -m twine upload dist\* rd /s /q ufpy.egg-info rd /s /q dist rd /s /q build - -pause \ No newline at end of file