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