pyutilities 2.5.2__tar.gz → 2.6.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. {pyutilities-2.5.2 → pyutilities-2.6.0}/LICENSE +21 -21
  2. {pyutilities-2.5.2 → pyutilities-2.6.0}/PKG-INFO +4 -4
  3. {pyutilities-2.5.2 → pyutilities-2.6.0}/README.md +42 -42
  4. {pyutilities-2.5.2 → pyutilities-2.6.0}/pyproject.toml +316 -316
  5. {pyutilities-2.5.2 → pyutilities-2.6.0}/src/pyutilities/config/configuration.py +0 -0
  6. {pyutilities-2.5.2 → pyutilities-2.6.0}/src/pyutilities/io/io_utils.py +45 -0
  7. pyutilities-2.6.0/src/pyutilities/xls/__init__.py +0 -0
  8. pyutilities-2.6.0/src/pyutilities/xls/xls_utils.py +98 -0
  9. {pyutilities-2.5.2 → pyutilities-2.6.0}/src/pyutilities/__init__.py +0 -0
  10. {pyutilities-2.5.2 → pyutilities-2.6.0}/src/pyutilities/cli/__init__.py +0 -0
  11. {pyutilities-2.5.2 → pyutilities-2.6.0}/src/pyutilities/cli/fedit.py +0 -0
  12. {pyutilities-2.5.2 → pyutilities-2.6.0}/src/pyutilities/cli/pyutils.py +0 -0
  13. {pyutilities-2.5.2 → pyutilities-2.6.0}/src/pyutilities/config/__init__.py +0 -0
  14. {pyutilities-2.5.2 → pyutilities-2.6.0}/src/pyutilities/defaults.py +0 -0
  15. {pyutilities-2.5.2 → pyutilities-2.6.0}/src/pyutilities/exception.py +0 -0
  16. {pyutilities-2.5.2 → pyutilities-2.6.0}/src/pyutilities/io/__init__.py +0 -0
  17. {pyutilities-2.5.2 → pyutilities-2.6.0}/src/pyutilities/log/__init__.py +0 -0
  18. {pyutilities-2.5.2 → pyutilities-2.6.0}/src/pyutilities/log/log_manager.py +0 -0
  19. {pyutilities-2.5.2 → pyutilities-2.6.0}/src/pyutilities/logging.py +0 -0
  20. {pyutilities-2.5.2 → pyutilities-2.6.0}/src/pyutilities/sys/__init__.py +0 -0
  21. {pyutilities-2.5.2 → pyutilities-2.6.0}/src/pyutilities/sys/sys_utils.py +0 -0
  22. {pyutilities-2.5.2 → pyutilities-2.6.0}/src/pyutilities/utils/__init__.py +0 -0
  23. {pyutilities-2.5.2 → pyutilities-2.6.0}/src/pyutilities/utils/common_utils.py +0 -0
  24. {pyutilities-2.5.2 → pyutilities-2.6.0}/src/pyutilities/utils/datetime_utils.py +0 -0
  25. {pyutilities-2.5.2 → pyutilities-2.6.0}/src/pyutilities/utils/decorators.py +0 -0
  26. {pyutilities-2.5.2 → pyutilities-2.6.0}/src/pyutilities/utils/lambdas.py +0 -0
  27. {pyutilities-2.5.2 → pyutilities-2.6.0}/src/pyutilities/utils/string_utils.py +0 -0
  28. {pyutilities-2.5.2 → pyutilities-2.6.0}/src/pyutilities/utils/structures.py +0 -0
  29. {pyutilities-2.5.2 → pyutilities-2.6.0}/src/pyutilities/web/__init__.py +0 -0
  30. {pyutilities-2.5.2 → pyutilities-2.6.0}/src/pyutilities/web/http_client.py +0 -0
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2022 Dmitrii
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Dmitrii
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyutilities
3
- Version: 2.5.2
3
+ Version: 2.6.0
4
4
  Summary: PyUtilities :: Useful python 3+ utilities library for various use cases.
5
5
  License-Expression: MIT
6
6
  License-File: LICENSE
@@ -27,7 +27,7 @@ Requires-Dist: fake-useragent (>=2.0,<3.0)
27
27
  Requires-Dist: loguru (==0.7.3)
28
28
  Requires-Dist: markdown (>=3.7,<4.0)
29
29
  Requires-Dist: marshmallow (>=4.1,<5.0)
30
- Requires-Dist: openpyxl (==3.1.5)
30
+ Requires-Dist: openpyxl (>=3.1,<4.0)
31
31
  Requires-Dist: paramiko (==5.*)
32
32
  Requires-Dist: pendulum (>=3.2,<4.0)
33
33
  Requires-Dist: prettytable (>=3.14,<4.0)
@@ -45,9 +45,9 @@ Requires-Dist: rich (>=15.0,<16.0)
45
45
  Requires-Dist: rich-pyfiglet (>=2.0,<3.0)
46
46
  Requires-Dist: ruamel.yaml (>=0.18,<1.0)
47
47
  Requires-Dist: urllib3 (>=2.6,<3.0)
48
- Requires-Dist: xlrd (>=2.0.1,<2.1.0)
48
+ Requires-Dist: xlrd (>=2.0,<3.0)
49
49
  Requires-Dist: xlwings (>=0.35,<1.0)
50
- Requires-Dist: xlwt (==1.3.0)
50
+ Requires-Dist: xlwt (>=1.3,<2.0)
51
51
  Project-URL: Bug Tracker, https://github.com/dmitry-ed-gusev/pyutilities/issues
52
52
  Project-URL: Documentation, https://github.com/dmitry-ed-gusev/pyutilities
53
53
  Project-URL: Homepage, https://pypi.org/project/pyutilities
@@ -1,42 +1,42 @@
1
- # Python Utilities Library (PyUtilities)
2
-
3
- **Dmitrii Gusev, 2018-2026.**
4
-
5
- ## Project Description
6
-
7
- Useful utilities functions for various needs for the **python 3.10+**. Containing many 'general purpose' functions for various areas. Using of this library may simplify/help with the development in various 'common' tasks.
8
-
9
- ## Installation
10
-
11
- There are no special pre-requisites for the library to be installed, except **python 3.10+**
12
- In order to install this library, use the following command:
13
-
14
- ```bash
15
- pip install pyutilities
16
- ```
17
-
18
- **Note: versions 2.1.0, 2.1.1 are intended only for the python version = 3.10 and can be installed only for it!**
19
-
20
- ## Tech Details
21
-
22
- ### Project modules
23
-
24
- - **cli** - Command Line Integration/Interface - module is under development now :)
25
- - **config** - configuration module, can be used anywhere
26
- - **io** - input/output utilities
27
- - **log** - logging helper classes
28
- - **sys** - system modules
29
- - **utils** - various common utilities (common, strings, dates, structures, etc.)
30
- - **web** - web client, simple web/http server
31
-
32
- ### Library Usage Examples
33
-
34
- See folder **[examples]** in the project root repository.
35
-
36
- ### Development Environment Setup
37
-
38
- There are various shell scripts in the root of the project repository, all of them are well-commented - see there.
39
-
40
- ### Publishing to PyPi Registry
41
-
42
- Look at the script **_deploy.sh** in the project repo root folder.
1
+ # Python Utilities Library (PyUtilities)
2
+
3
+ **Dmitrii Gusev, 2018-2026.**
4
+
5
+ ## Project Description
6
+
7
+ Useful utilities functions for various needs for the **python 3.10+**. Containing many 'general purpose' functions for various areas. Using of this library may simplify/help with the development in various 'common' tasks.
8
+
9
+ ## Installation
10
+
11
+ There are no special pre-requisites for the library to be installed, except **python 3.10+**
12
+ In order to install this library, use the following command:
13
+
14
+ ```bash
15
+ pip install pyutilities
16
+ ```
17
+
18
+ **Note: versions 2.1.0, 2.1.1 are intended only for the python version = 3.10 and can be installed only for it!**
19
+
20
+ ## Tech Details
21
+
22
+ ### Project modules
23
+
24
+ - **cli** - Command Line Integration/Interface - module is under development now :)
25
+ - **config** - configuration module, can be used anywhere
26
+ - **io** - input/output utilities
27
+ - **log** - logging helper classes
28
+ - **sys** - system modules
29
+ - **utils** - various common utilities (common, strings, dates, structures, etc.)
30
+ - **web** - web client, simple web/http server
31
+
32
+ ### Library Usage Examples
33
+
34
+ See folder **[examples]** in the project root repository.
35
+
36
+ ### Development Environment Setup
37
+
38
+ There are various shell scripts in the root of the project repository, all of them are well-commented - see there.
39
+
40
+ ### Publishing to PyPi Registry
41
+
42
+ Look at the script **_deploy.sh** in the project repo root folder.
@@ -1,316 +1,316 @@
1
- ####################################################################################################
2
- #
3
- # Main configuration file for the [pyutilities] library. The whole project configuration (any
4
- # setting) should be put here. Also configuration for dependencies and all code quality tools.
5
- #
6
- # Notes (code quality, etc.):
7
- # - project line length = 110 symbols (black, flake8)
8
- # - most of modules should be typed (used mypy stubs libraries)
9
- #
10
- # Created: Dmitrii Gusev, 30.05.2025
11
- # Modified: Dmitrii Gusev, 27.05.2026
12
- #
13
- ####################################################################################################
14
-
15
- # -- build system information
16
- [build-system]
17
- requires = ["poetry-core>=2.0.0,<3.0.0"]
18
- build-backend = "poetry.core.masonry.api"
19
-
20
- # -- project / poetry utility meta-information
21
- [project]
22
- name = "pyutilities"
23
- version = "2.5.2"
24
- description = "PyUtilities :: Useful python 3+ utilities library for various use cases."
25
- authors = [
26
- {name = "Dmitrii Gusev", email = "dmitry.ed.gusev@gmail.com"},
27
- ]
28
- license = "MIT"
29
- readme = "README.md"
30
- requires-python = ">=3.10,<4"
31
- keywords = [
32
- "Python Utilities", "Useful Functions", "String Utilities", "CLI Functions", "toolset", "library",
33
- "System Utilities", "Useful Decorators", "IO Functions"
34
- ]
35
- classifiers = [
36
- "Development Status :: 6 - Mature",
37
- "Operating System :: OS Independent",
38
- "Programming Language :: Python",
39
- "Programming Language :: Python :: 3",
40
- "Programming Language :: Python :: 3.10",
41
- "Programming Language :: Python :: 3.11",
42
- "Programming Language :: Python :: 3.12",
43
- "Programming Language :: Python :: 3.13",
44
- "Programming Language :: Python :: 3.14",
45
- "License :: OSI Approved :: MIT License",
46
- "Intended Audience :: Developers",
47
- "Intended Audience :: System Administrators",
48
- "Topic :: Utilities",
49
- "Typing :: Typed"
50
- ]
51
-
52
- # - project runtime dependencies
53
- dependencies = [
54
-
55
- # -- loguru
56
- "loguru==0.7.3",
57
-
58
- # -- ms word / ms excel libraries
59
- "xlrd~=2.0.1", # - allowed: >=2.0.1 <2.1.0
60
- "xlwt==1.3.0",
61
- "xlwings~=0.35",
62
- "openpyxl==3.1.5",
63
-
64
- # -- data validation and marshalling (JSON/YAML) --
65
- "pydantic (>=2.12.5,<3.0.0)",
66
- "pydantic-yaml ~=1.6",
67
- "pydantic-settings ==2.*",
68
- "marshmallow ~=4.1",
69
- "pyyaml ==6.*",
70
- "ruamel.yaml ~=0.18",
71
-
72
- # -- technical libraries
73
- "urllib3~=2.6", # - allowed: >=2.3.0 <3.0.0
74
- "paramiko ==5.*",
75
- "requests~=2.32", # - allowed: >=2.32.0 <3.0.0
76
- "markdown~=3.7", # - allowed: >=3.7.0 <4.0.0
77
- "prettytable~=3.14", # - allowed: >=3.14.0 <4.0.0
78
- "fake-useragent~=2.0", # - allowed: >=2.0.0 <3.0.0
79
- "click~=8.3",
80
- "python-dotenv ~=1.2", # - loading various .env configs
81
-
82
- # -- terminal pseudo-graphics / pretty output
83
- "prettytable ~=3.17", # - terminal tables
84
- "pyfiglet ~=1.0", # - ASCII graphics
85
- "rich ~=15.0",
86
- "rich-pyfiglet ~=2.0", # - ASCII graphics addon (colors)
87
-
88
- # -- datetime utilities
89
- "pendulum ~=3.2",
90
- "python-dateutil ~=2.9",
91
- "pytz ==2026.*"
92
-
93
- ]
94
-
95
- # -- additional dependencies groups (test/research/etc. - not runtime)
96
- [dependency-groups]
97
-
98
- dev = [
99
-
100
- # -- pytest library and extensions --
101
- "pytest ==9.*", # - allowed any version < 10.0.0
102
- "pytest-env ==1.*",
103
- "pytest-cov ==7.*",
104
- "pytest-mock ==3.*",
105
- "pytest-pep8 ==1.0.6",
106
- "pytest-flakes ==4.0.5",
107
- "pytest-isort ==4.0.0",
108
- "pytest-black ==0.6.0",
109
- "pytest-variables[hjson,yaml,toml] ==3.1.0",
110
-
111
- # -- testing-related libraries --
112
- "mock ==5.*",
113
- "mockito ~=2",
114
- "nose2 ==0.*",
115
- "hypothesis ==6.*",
116
-
117
- # -- typing libraries + typing stubs for runtime dependencies --
118
- "mypy ==2.*", # - typing library
119
- "types-six ==1.*",
120
- "types-mock ==5.*",
121
- "types-paramiko ==4.*",
122
- "types-requests ==2.*",
123
- "types-markdown ==3.*",
124
- "types-PyYAML ==6.*",
125
- "types-flake8-bugbear ==25.*",
126
-
127
- # -- code quality control libraries
128
- "flake8 ==7.*",
129
- "flake8-pyproject ~=1.2",
130
- "flake8-bandit ~=4.1",
131
- "flake8-bugbear ==25.*",
132
- "black ~=26.0", # - code formatter
133
- "pylint ~=4.0",
134
- "pre-commit ~=4.0", # - pre-commit hook
135
- "bandit ==1.9.*",
136
- "isort[requirements_deprecated_finder,pipfile_deprecated_finder] ==8.*",
137
- "pyflakes ~=3.4",
138
- "codeaudit ~=1.4", # - SAST local analysis
139
-
140
- # -- profiling/debugging libraries
141
- "snakeviz ==2.2.2",
142
- "memory-profiler ==0.61.0",
143
- "py-spy ~=0.4",
144
- "viztracer ==1.1.1",
145
-
146
- # -- development-related process libraries
147
- "sphinx ==8.* ; python_version == '3.10'", # - docs lib - for python == 3.10
148
- "sphinx ==9.* ; python_version >= '3.11' and python_version < '4.0'", # - docs lib - for python > 3.10
149
-
150
- "watchdog ==6.0.0", # - file monitor and auto-reloader
151
- "responses ==0.*", # - used by many testing/code quality libraries
152
-
153
- # -- readline module depending on the platform
154
- "pyreadline3 ==3.* ; sys_platform == 'win32' or sys_platform == 'cygwin'",
155
- "gnureadline ==8.2.13 ; sys_platform != 'win32'"
156
-
157
- ]
158
-
159
- research = [ # - research dependencies (Jupyter, etc.)
160
-
161
- "notebook~=7.5" # allowed < 8.0.0
162
-
163
- ]
164
-
165
- [tool.poetry]
166
- packages = [{include = "pyutilities", from = "src"}]
167
-
168
- # -- poetry :: source repositories setup
169
- # [[tool.poetry.source]]
170
- # name = "severstal_repo"
171
- # url = "https://repo.severstal.severstalgroup.com/artifactory/api/pypi/pypi/simple/"
172
- # priority = "primary" # - primary packages source
173
- # priority = "supplemental" # - packages source will be used when primary is not available...
174
-
175
- [tool.poetry.dependencies]
176
- python = ">=3.10,<4"
177
-
178
- [project.urls]
179
- Homepage = "https://pypi.org/project/pyutilities"
180
- Repository = "https://github.com/dmitry-ed-gusev/pyutilities"
181
- Documentation = "https://github.com/dmitry-ed-gusev/pyutilities"
182
- "Bug Tracker" = "https://github.com/dmitry-ed-gusev/pyutilities/issues"
183
-
184
- [project.scripts]
185
- pyutils = 'pyutilities.cli.pyutils:pyutils'
186
-
187
- # -- flake8 tool
188
- [tool.flake8]
189
- # - list of ignored issues for the flake8 tool
190
- # - (E501 - long line, F401 - unused import, E203 - whitespace before ':' - black puts it)
191
- ignore = ['F401']
192
- # - max cognitive complexity for statements
193
- max-complexity = 10
194
- # - line length aligned with same setting for [black] (88 chars by default) -> project value = 110
195
- max-line-length = 110
196
- # - ignored violations, specific per files
197
- per-file-ignores = [
198
- 'tests/**:S101, S311',
199
- ]
200
-
201
- # -- pylint tool
202
- [tool.pylint.MASTER]
203
- disable = [
204
- 'C0114', # missing-module-docstring
205
- 'C0115', # missing-class-docstring
206
- 'C0116', # missing-function-docstring
207
- ]
208
-
209
- [tool.pylint.FORMAT]
210
- max-line-length=110
211
- max-module-lines=1000
212
-
213
- # -- isort tool
214
- [tool.isort]
215
- profile = 'black'
216
- multi_line_output = 3
217
- line_length = 110
218
- include_trailing_comma = true
219
- skip_gitignore = true
220
- skip_glob = ["**/migrations/*", "**/settings/*"]
221
- # src_paths = ["./", "src/"]
222
- src_paths = ["./src/"]
223
-
224
- # -- black tool configuration
225
- [tool.black]
226
- line_length = 110
227
- target-version = ['py310']
228
- extend-exclude = '''
229
- (
230
- migrations # Alembic DB migrations
231
- )
232
- '''
233
-
234
- # -- bandit tool
235
- [tool.bandit]
236
- exclude_dirs = ["tests"]
237
- tests = ["B201", "B301"]
238
- skips = ["B101", "B601"]
239
-
240
- # -- mypy tool
241
- [tool.mypy]
242
- mypy_path = "./"
243
- python_version = "3.10"
244
- follow_imports = "silent"
245
- strict_optional = true
246
- warn_redundant_casts = true
247
- warn_unused_ignores = true
248
- warn_return_any = true
249
- warn_unused_configs = true
250
- disallow_any_generics = true
251
- check_untyped_defs = true
252
- no_implicit_reexport = true
253
- allow_untyped_defs = true
254
- # disallow_untyped_defs = true
255
- # - mypy will ignore missing types defs imports
256
- ignore_missing_imports = true
257
- # - force mypy to analyze as best as its can module without types defs
258
- follow_untyped_imports = true
259
-
260
- # [[tool.mypy.overrides]]
261
- # module = "pyutilities.web.http_client"
262
- # disable_error_code = ["R0913", "too-many-arguments", "unused-argument"]
263
-
264
- # -- pytest tool
265
- [tool.pytest.ini_options]
266
- minversion = "6.0"
267
- addopts = """
268
- --cov=./src/pyutilities --verbose --cov-report=html --cov-report=xml --cov-report=json --cov-report=annotate --capture=sys -rx --durations=0 --full-trace --color=auto --hypothesis-show-statistics --hypothesis-verbosity=verbose
269
-
270
- """
271
- testpaths = [
272
- "tests/",
273
- "integration/",
274
- ]
275
- mock_use_standalone_module = true
276
- mock_traceback_monkeypatch = false
277
-
278
- # - tests markers - tests can be grouped and executed by them
279
- markers = [
280
-
281
- "functional: these tests are significantly slower as they run the whole CLI script",
282
-
283
- ]
284
-
285
- # -- env variables for tests in pytest
286
- [tool.pytest_env]
287
- # MY_VARIABLE = "my_value"
288
- PYTHONTRACEMALLOC = 20
289
-
290
- # -- coverage tool configuration (coveragerc)
291
- [tool.coverage.run]
292
- branch = true
293
- data_file = ".coverage/.coverage"
294
- omit = [
295
- '*__init__*',
296
- '*temp*',
297
- '*tests\*'
298
- ]
299
-
300
- [tool.coverage.report]
301
- show_missing = true
302
- # - show 2 decimal digits for coverage report values
303
- precision = 2
304
- # skip_covered = true
305
-
306
- [tool.coverage.html]
307
- directory = ".coverage/htmlcoverage"
308
- title = "Python Utilities :: Tests Coverage Report."
309
-
310
- [tool.coverage.xml]
311
- output = ".coverage/coverage.xml"
312
-
313
- # -- this setting is used by coverage.py, ignored by pytest-cov
314
- [tool.coverage.json]
315
- output = ".coverage/coverage.json"
316
- pretty_print = true
1
+ ####################################################################################################
2
+ #
3
+ # Main configuration file for the [pyutilities] library. The whole project configuration (any
4
+ # setting) should be put here. Also configuration for dependencies and all code quality tools.
5
+ #
6
+ # Notes (code quality, etc.):
7
+ # - project line length = 110 symbols (black, flake8)
8
+ # - most of modules should be typed (used mypy stubs libraries)
9
+ #
10
+ # Created: Dmitrii Gusev, 30.05.2025
11
+ # Modified: Dmitrii Gusev, 24.06.2026
12
+ #
13
+ ####################################################################################################
14
+
15
+ # -- build system information
16
+ [build-system]
17
+ requires = ["poetry-core>=2.0.0,<3.0.0"]
18
+ build-backend = "poetry.core.masonry.api"
19
+
20
+ # -- project / poetry utility meta-information
21
+ [project]
22
+ name = "pyutilities"
23
+ version = "2.6.0"
24
+ description = "PyUtilities :: Useful python 3+ utilities library for various use cases."
25
+ authors = [
26
+ {name = "Dmitrii Gusev", email = "dmitry.ed.gusev@gmail.com"},
27
+ ]
28
+ license = "MIT"
29
+ readme = "README.md"
30
+ requires-python = ">=3.10,<4"
31
+ keywords = [
32
+ "Python Utilities", "Useful Functions", "String Utilities", "CLI Functions", "toolset", "library",
33
+ "System Utilities", "Useful Decorators", "IO Functions"
34
+ ]
35
+ classifiers = [
36
+ "Development Status :: 6 - Mature",
37
+ "Operating System :: OS Independent",
38
+ "Programming Language :: Python",
39
+ "Programming Language :: Python :: 3",
40
+ "Programming Language :: Python :: 3.10",
41
+ "Programming Language :: Python :: 3.11",
42
+ "Programming Language :: Python :: 3.12",
43
+ "Programming Language :: Python :: 3.13",
44
+ "Programming Language :: Python :: 3.14",
45
+ "License :: OSI Approved :: MIT License",
46
+ "Intended Audience :: Developers",
47
+ "Intended Audience :: System Administrators",
48
+ "Topic :: Utilities",
49
+ "Typing :: Typed"
50
+ ]
51
+
52
+ # - project runtime dependencies
53
+ dependencies = [
54
+
55
+ # -- loguru
56
+ "loguru==0.7.3",
57
+
58
+ # -- ms word / ms excel libraries
59
+ "xlrd ~=2.0",
60
+ "xlwt ~=1.3",
61
+ "xlwings ~=0.35",
62
+ "openpyxl ~=3.1",
63
+
64
+ # -- data validation and marshalling (JSON/YAML) --
65
+ "pydantic (>=2.12.5,<3.0.0)",
66
+ "pydantic-yaml ~=1.6",
67
+ "pydantic-settings ==2.*",
68
+ "marshmallow ~=4.1",
69
+ "pyyaml ==6.*",
70
+ "ruamel.yaml ~=0.18",
71
+
72
+ # -- technical libraries
73
+ "urllib3~=2.6", # - allowed: >=2.3.0 <3.0.0
74
+ "paramiko ==5.*",
75
+ "requests~=2.32", # - allowed: >=2.32.0 <3.0.0
76
+ "markdown~=3.7", # - allowed: >=3.7.0 <4.0.0
77
+ "prettytable~=3.14", # - allowed: >=3.14.0 <4.0.0
78
+ "fake-useragent~=2.0", # - allowed: >=2.0.0 <3.0.0
79
+ "click~=8.3",
80
+ "python-dotenv ~=1.2", # - loading various .env configs
81
+
82
+ # -- terminal pseudo-graphics / pretty output
83
+ "prettytable ~=3.17", # - terminal tables
84
+ "pyfiglet ~=1.0", # - ASCII graphics
85
+ "rich ~=15.0",
86
+ "rich-pyfiglet ~=2.0", # - ASCII graphics addon (colors)
87
+
88
+ # -- datetime utilities
89
+ "pendulum ~=3.2",
90
+ "python-dateutil ~=2.9",
91
+ "pytz ==2026.*"
92
+
93
+ ]
94
+
95
+ # -- additional dependencies groups (test/research/etc. - not runtime)
96
+ [dependency-groups]
97
+
98
+ dev = [
99
+
100
+ # -- pytest library and extensions --
101
+ "pytest ==9.*", # - allowed any version < 10.0.0
102
+ "pytest-env ==1.*",
103
+ "pytest-cov ==7.*",
104
+ "pytest-mock ==3.*",
105
+ # "pytest-pep8 ==1.0.6",
106
+ "pytest-flakes ==4.0.5",
107
+ "pytest-isort ==4.0.0",
108
+ # "pytest-black ==0.6.0",
109
+ "pytest-variables[hjson,yaml,toml] ==3.1.0",
110
+
111
+ # -- testing-related libraries --
112
+ "mock ==5.*",
113
+ "mockito ~=2",
114
+ "nose2 ==0.*",
115
+ "hypothesis ==6.*",
116
+
117
+ # -- typing libraries + typing stubs for runtime dependencies --
118
+ "mypy ==2.*", # - typing library
119
+ "types-six ==1.*",
120
+ "types-mock ==5.*",
121
+ "types-paramiko ==5.*",
122
+ "types-requests ==2.*",
123
+ "types-markdown ==3.*",
124
+ "types-PyYAML ==6.*",
125
+ "types-flake8-bugbear ==25.*",
126
+
127
+ # -- code quality control libraries
128
+ "flake8 ==7.*",
129
+ "flake8-pyproject ~=1.2",
130
+ "flake8-bandit ~=4.1",
131
+ "flake8-bugbear ==25.*",
132
+ "black ~=26.0", # - code formatter
133
+ "pylint ~=4.0",
134
+ "pre-commit ~=4.0", # - pre-commit hook
135
+ "bandit ==1.9.*",
136
+ "isort[requirements_deprecated_finder,pipfile_deprecated_finder] ==8.*",
137
+ "pyflakes ~=3.4",
138
+ "codeaudit ~=1.4", # - SAST local analysis
139
+
140
+ # -- profiling/debugging libraries
141
+ "snakeviz ==2.2.2",
142
+ "memory-profiler ==0.61.0",
143
+ "py-spy ~=0.4",
144
+ "viztracer ==1.1.1",
145
+
146
+ # -- development-related process libraries
147
+ "sphinx ==8.* ; python_version == '3.10'", # - docs lib - for python == 3.10
148
+ "sphinx ==9.* ; python_version >= '3.11' and python_version < '4.0'", # - docs lib - for python > 3.10
149
+
150
+ "watchdog ==6.0.0", # - file monitor and auto-reloader
151
+ "responses ==0.*", # - used by many testing/code quality libraries
152
+
153
+ # -- readline module depending on the platform
154
+ "pyreadline3 ==3.* ; sys_platform == 'win32' or sys_platform == 'cygwin'",
155
+ "gnureadline ==8.* ; sys_platform != 'win32'"
156
+
157
+ ]
158
+
159
+ research = [ # - research dependencies (Jupyter, etc.)
160
+
161
+ "notebook~=7.5" # allowed < 8.0.0
162
+
163
+ ]
164
+
165
+ [tool.poetry]
166
+ packages = [{include = "pyutilities", from = "src"}]
167
+
168
+ # -- poetry :: source repositories setup
169
+ # [[tool.poetry.source]]
170
+ # name = "severstal_repo"
171
+ # url = "https://repo.severstal.severstalgroup.com/artifactory/api/pypi/pypi/simple/"
172
+ # priority = "primary" # - primary packages source
173
+ # priority = "supplemental" # - packages source will be used when primary is not available...
174
+
175
+ [tool.poetry.dependencies]
176
+ python = ">=3.10,<4"
177
+
178
+ [project.urls]
179
+ Homepage = "https://pypi.org/project/pyutilities"
180
+ Repository = "https://github.com/dmitry-ed-gusev/pyutilities"
181
+ Documentation = "https://github.com/dmitry-ed-gusev/pyutilities"
182
+ "Bug Tracker" = "https://github.com/dmitry-ed-gusev/pyutilities/issues"
183
+
184
+ [project.scripts]
185
+ pyutils = 'pyutilities.cli.pyutils:pyutils'
186
+
187
+ # -- flake8 tool
188
+ [tool.flake8]
189
+ # - list of ignored issues for the flake8 tool
190
+ # - (E501 - long line, F401 - unused import, E203 - whitespace before ':' - black puts it)
191
+ ignore = ['F401']
192
+ # - max cognitive complexity for statements
193
+ max-complexity = 10
194
+ # - line length aligned with same setting for [black] (88 chars by default) -> project value = 110
195
+ max-line-length = 110
196
+ # - ignored violations, specific per files
197
+ per-file-ignores = [
198
+ 'tests/**:S101, S311',
199
+ ]
200
+
201
+ # -- pylint tool
202
+ [tool.pylint.MASTER]
203
+ disable = [
204
+ 'C0114', # missing-module-docstring
205
+ 'C0115', # missing-class-docstring
206
+ 'C0116', # missing-function-docstring
207
+ ]
208
+
209
+ [tool.pylint.FORMAT]
210
+ max-line-length=110
211
+ max-module-lines=1000
212
+
213
+ # -- isort tool
214
+ [tool.isort]
215
+ profile = 'black'
216
+ multi_line_output = 3
217
+ line_length = 110
218
+ include_trailing_comma = true
219
+ skip_gitignore = true
220
+ skip_glob = ["**/migrations/*", "**/settings/*"]
221
+ # src_paths = ["./", "src/"]
222
+ src_paths = ["./src/"]
223
+
224
+ # -- black tool configuration
225
+ [tool.black]
226
+ line_length = 110
227
+ target-version = ['py310']
228
+ extend-exclude = '''
229
+ (
230
+ migrations # Alembic DB migrations
231
+ )
232
+ '''
233
+
234
+ # -- bandit tool
235
+ [tool.bandit]
236
+ exclude_dirs = ["tests"]
237
+ tests = ["B201", "B301"]
238
+ skips = ["B101", "B601"]
239
+
240
+ # -- mypy tool
241
+ [tool.mypy]
242
+ mypy_path = "./"
243
+ python_version = "3.14"
244
+ follow_imports = "silent"
245
+ strict_optional = true
246
+ warn_redundant_casts = true
247
+ warn_unused_ignores = true
248
+ warn_return_any = true
249
+ warn_unused_configs = true
250
+ disallow_any_generics = true
251
+ check_untyped_defs = true
252
+ no_implicit_reexport = true
253
+ allow_untyped_defs = true
254
+ # disallow_untyped_defs = true
255
+ # - mypy will ignore missing types defs imports
256
+ ignore_missing_imports = true
257
+ # - force mypy to analyze as best as its can module without types defs
258
+ follow_untyped_imports = true
259
+
260
+ # [[tool.mypy.overrides]]
261
+ # module = "pyutilities.web.http_client"
262
+ # disable_error_code = ["R0913", "too-many-arguments", "unused-argument"]
263
+
264
+ # -- pytest tool
265
+ [tool.pytest.ini_options]
266
+ minversion = "6.0"
267
+ addopts = """
268
+ --cov=./src/pyutilities --verbose --cov-report=html --cov-report=xml --cov-report=json --cov-report=annotate --capture=sys -rx --durations=0 --full-trace --color=auto --hypothesis-show-statistics --hypothesis-verbosity=verbose
269
+
270
+ """
271
+ testpaths = [
272
+ "tests/",
273
+ "integration/",
274
+ ]
275
+ mock_use_standalone_module = true
276
+ mock_traceback_monkeypatch = false
277
+
278
+ # - tests markers - tests can be grouped and executed by them
279
+ markers = [
280
+
281
+ "functional: these tests are significantly slower as they run the whole CLI script",
282
+
283
+ ]
284
+
285
+ # -- env variables for tests in pytest
286
+ [tool.pytest_env]
287
+ # MY_VARIABLE = "my_value"
288
+ PYTHONTRACEMALLOC = 20
289
+
290
+ # -- coverage tool configuration (coveragerc)
291
+ [tool.coverage.run]
292
+ branch = true
293
+ data_file = ".coverage/.coverage"
294
+ omit = [
295
+ '*__init__*',
296
+ '*temp*',
297
+ '*tests\*'
298
+ ]
299
+
300
+ [tool.coverage.report]
301
+ show_missing = true
302
+ # - show 2 decimal digits for coverage report values
303
+ precision = 2
304
+ # skip_covered = true
305
+
306
+ [tool.coverage.html]
307
+ directory = ".coverage/htmlcoverage"
308
+ title = "Python Utilities :: Tests Coverage Report."
309
+
310
+ [tool.coverage.xml]
311
+ output = ".coverage/coverage.xml"
312
+
313
+ # -- this setting is used by coverage.py, ignored by pytest-cov
314
+ [tool.coverage.json]
315
+ output = ".coverage/coverage.json"
316
+ pretty_print = true
@@ -145,5 +145,50 @@ def file_size_str(file_path: str) -> str:
145
145
  return "unknown"
146
146
 
147
147
 
148
+ def clear_directory_except_files(directory_path: str, files_to_keep: list[str], trace: bool = False) -> int:
149
+ """Cleanup folder <directory_path>, keeping files by list <files_to_keep>. Subdirectories are
150
+ not affected - they won't be removed (files in the subdirectories won't be touched as well).
151
+ Usage:
152
+ clear_directory_except_files("example_folder", ["keep_files.txt", "another_file.txt"])
153
+ """
154
+
155
+ if not os.path.exists(directory_path) or not os.path.isdir(directory_path):
156
+ log.debug("Path %s doesn't exist or not a directory!", directory_path)
157
+ return 0
158
+
159
+ counter: int = 0
160
+ for filename in os.listdir(directory_path):
161
+ file_path = os.path.join(directory_path, filename)
162
+ if os.path.isfile(file_path) and filename not in files_to_keep:
163
+ try:
164
+ os.remove(file_path)
165
+ counter += 1
166
+ if trace:
167
+ log.debug("File %s deleted OK.", file_path)
168
+ except FileNotFoundError:
169
+ log.debug("File %s was already removed.", file_path)
170
+ except PermissionError:
171
+ log.error("Permission denied when trying to delete %s!", file_path)
172
+ except OSError as e:
173
+ log.exception("Error deleting file %s. Error: %s.", file_path, e)
174
+
175
+ return counter
176
+
177
+
178
+ def clear_directory_except_files_recursive(directory_path, files_to_keep):
179
+ for root, _, files in os.walk(directory_path):
180
+ for filename in files:
181
+ file_path = os.path.join(root, filename)
182
+ if os.path.isfile(file_path) and filename not in files_to_keep:
183
+ try:
184
+ os.remove(file_path)
185
+ print(f"Файл {file_path} успешно удалён")
186
+ except Exception as e:
187
+ print(f"Ошибка при удалении {file_path}: {e}")
188
+
189
+
190
+ # Очистить папку `example_folder` от всех файлов, кроме `keep_files.txt` и `another_file.txt`, рекурсивно
191
+ # clear_directory_except_files_recursive("example_folder", ["keep_files.txt", "another_file.txt"])
192
+
148
193
  if __name__ == "__main__":
149
194
  print(MSG_MODULE_ISNT_RUNNABLE)
File without changes
@@ -0,0 +1,98 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ """
4
+ Useful Excel utilities for improving excel working in python.
5
+
6
+ Created: Dmitrii Gusev, 24.06.2026
7
+ Modified: Dmitrii Gusev, 24.06.2026
8
+ """
9
+
10
+ from openpyxl.cell.cell import Cell
11
+ from openpyxl.styles import Alignment, Font
12
+ from openpyxl.utils import get_column_letter
13
+ from openpyxl.worksheet.worksheet import Worksheet
14
+
15
+ from pyutilities.utils.string_utils import is_empty
16
+
17
+ # - styling constants/defaults
18
+ FONT: Font = Font()
19
+ FONT_RED: Font = Font(color="FF0000") # red font
20
+ FONT_GREEN: Font = Font(color="00BB00") # green font
21
+ FONT_BOLD: Font = Font(bold=True)
22
+ FONT_BOLD_RED: Font = Font(bold=True, color="FF0000") # red font, bold
23
+ FONT_BOLD_GREEN: Font = Font(bold=True, color="00BB00") # green font, bold
24
+ ALIGNMENT_CENTER: Alignment = Alignment(horizontal="center", vertical="center", wrapText=True)
25
+
26
+
27
+ class XlsSheet:
28
+ """Utility class for working with openpyxl excel worksheet."""
29
+
30
+ def __init__(self, ws: Worksheet):
31
+ self.__ws = ws
32
+
33
+ def init_cell(
34
+ self,
35
+ address: str,
36
+ value: str,
37
+ bold: bool = False,
38
+ aligned: bool = False,
39
+ color: str = None,
40
+ width: int = 0,
41
+ ) -> Cell:
42
+ """Simple yet powerful method for cell initialization. Can init essential cell parameters."""
43
+
44
+ cell = self.__ws[address]
45
+ cell.value = value
46
+
47
+ if bold: # font boldness
48
+ cell.font = FONT_BOLD
49
+
50
+ if aligned: # cell text alignment
51
+ cell.alignment = ALIGNMENT_CENTER
52
+
53
+ if not is_empty(color): # cell font coloring/boldness
54
+ if color == "red":
55
+ if bold:
56
+ cell.font = FONT_BOLD_RED
57
+ else:
58
+ cell.font = FONT_RED
59
+ elif color == "green":
60
+ if bold:
61
+ cell.font = FONT_BOLD_GREEN
62
+ else:
63
+ cell.font = FONT_GREEN
64
+
65
+ if width > 0: # column width
66
+ self.__ws.column_dimensions[cell.column_letter].width = width
67
+
68
+ return cell
69
+
70
+ def init_cell_bold(
71
+ self, address, value, aligned: bool = False, color: str = None, width: int = 0
72
+ ) -> Cell:
73
+ """TBD"""
74
+ return self.init_cell(
75
+ address=address, value=value, bold=True, aligned=aligned, color=color, width=width
76
+ )
77
+
78
+ # pylint: disable=too-many-arguments, too-many-positional-arguments
79
+ def init_cell_addr(
80
+ self,
81
+ row: int,
82
+ column: int,
83
+ value: str,
84
+ bold: bool = False,
85
+ aligned: bool = False,
86
+ color: str = None,
87
+ width: int = 0,
88
+ ) -> Cell:
89
+ """TBD"""
90
+
91
+ letter: str = get_column_letter(column)
92
+ return self.init_cell(
93
+ address=f"{letter}{row}", value=value, bold=bold, aligned=aligned, color=color, width=width
94
+ )
95
+
96
+ def set_column_width(self, column: str, width: int):
97
+ """TBD"""
98
+ self.__ws.column_dimensions[column].width = width