pyutilities 2.1.2__tar.gz → 2.4.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 (29) hide show
  1. {pyutilities-2.1.2 → pyutilities-2.4.0}/PKG-INFO +29 -7
  2. {pyutilities-2.1.2 → pyutilities-2.4.0}/docs/README-PUB.md +9 -2
  3. pyutilities-2.4.0/pyproject.toml +315 -0
  4. {pyutilities-2.1.2 → pyutilities-2.4.0}/src/pyutilities/__init__.py +2 -0
  5. pyutilities-2.4.0/src/pyutilities/cli/pyutils.py +28 -0
  6. {pyutilities-2.1.2 → pyutilities-2.4.0}/src/pyutilities/config/configuration.py +2 -1
  7. {pyutilities-2.1.2 → pyutilities-2.4.0}/src/pyutilities/io/io_utils.py +16 -4
  8. pyutilities-2.4.0/src/pyutilities/log/log_manager.py +325 -0
  9. {pyutilities-2.1.2 → pyutilities-2.4.0}/src/pyutilities/sys/sys_utils.py +12 -6
  10. {pyutilities-2.1.2 → pyutilities-2.4.0}/src/pyutilities/utils/common_utils.py +11 -56
  11. pyutilities-2.4.0/src/pyutilities/utils/datetime_utils.py +78 -0
  12. pyutilities-2.4.0/src/pyutilities/utils/decorators.py +195 -0
  13. {pyutilities-2.1.2 → pyutilities-2.4.0}/src/pyutilities/utils/lambdas.py +17 -15
  14. {pyutilities-2.1.2 → pyutilities-2.4.0}/src/pyutilities/utils/string_utils.py +147 -48
  15. pyutilities-2.4.0/src/pyutilities/web/__init__.py +0 -0
  16. {pyutilities-2.1.2 → pyutilities-2.4.0}/src/pyutilities/web/http_client.py +2 -2
  17. pyutilities-2.1.2/pyproject.toml +0 -244
  18. pyutilities-2.1.2/src/pyutilities/utils/decorators.py +0 -88
  19. {pyutilities-2.1.2 → pyutilities-2.4.0}/LICENSE +0 -0
  20. {pyutilities-2.1.2 → pyutilities-2.4.0}/src/pyutilities/cli/__init__.py +0 -0
  21. {pyutilities-2.1.2 → pyutilities-2.4.0}/src/pyutilities/cli/fedit.py +0 -0
  22. {pyutilities-2.1.2 → pyutilities-2.4.0}/src/pyutilities/config/__init__.py +0 -0
  23. {pyutilities-2.1.2 → pyutilities-2.4.0}/src/pyutilities/defaults.py +0 -0
  24. {pyutilities-2.1.2 → pyutilities-2.4.0}/src/pyutilities/exception.py +0 -0
  25. {pyutilities-2.1.2 → pyutilities-2.4.0}/src/pyutilities/io/__init__.py +0 -0
  26. {pyutilities-2.1.2/src/pyutilities/sys → pyutilities-2.4.0/src/pyutilities/log}/__init__.py +0 -0
  27. {pyutilities-2.1.2 → pyutilities-2.4.0}/src/pyutilities/logging.py +0 -0
  28. {pyutilities-2.1.2/src/pyutilities/web → pyutilities-2.4.0/src/pyutilities/sys}/__init__.py +0 -0
  29. {pyutilities-2.1.2 → pyutilities-2.4.0}/src/pyutilities/utils/__init__.py +0 -0
@@ -1,10 +1,10 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyutilities
3
- Version: 2.1.2
4
- Summary: PyUtilities :: Useful python 3 utilities library for various use cases.
3
+ Version: 2.4.0
4
+ Summary: PyUtilities :: Useful python 3+ utilities library for various use cases.
5
5
  License-Expression: MIT
6
6
  License-File: LICENSE
7
- Keywords: Python Utilities,Useful Functions,String Utilities,CLI Functions,toolset,library,System Utilities
7
+ Keywords: Python Utilities,Useful Functions,String Utilities,CLI Functions,toolset,library,System Utilities,Useful Decorators,IO Functions
8
8
  Author: Dmitrii Gusev
9
9
  Author-email: dmitry.ed.gusev@gmail.com
10
10
  Requires-Python: >=3.10,<4
@@ -16,21 +16,36 @@ Classifier: Programming Language :: Python :: 3.10
16
16
  Classifier: Programming Language :: Python :: 3.11
17
17
  Classifier: Programming Language :: Python :: 3.12
18
18
  Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
19
20
  Classifier: License :: OSI Approved :: MIT License
20
21
  Classifier: Intended Audience :: Developers
22
+ Classifier: Intended Audience :: System Administrators
21
23
  Classifier: Topic :: Utilities
22
24
  Classifier: Typing :: Typed
25
+ Requires-Dist: click (>=8.3,<9.0)
23
26
  Requires-Dist: fake-useragent (>=2.0,<3.0)
24
27
  Requires-Dist: loguru (==0.7.3)
25
28
  Requires-Dist: markdown (>=3.7,<4.0)
29
+ Requires-Dist: marshmallow (>=4.1,<5.0)
26
30
  Requires-Dist: openpyxl (==3.1.5)
27
31
  Requires-Dist: paramiko (==4.*)
32
+ Requires-Dist: pendulum (>=3.2,<4.0)
28
33
  Requires-Dist: prettytable (>=3.14,<4.0)
34
+ Requires-Dist: prettytable (>=3.17,<4.0)
35
+ Requires-Dist: pydantic (>=2.12.5,<3.0.0)
36
+ Requires-Dist: pydantic-settings (==2.*)
37
+ Requires-Dist: pydantic-yaml (==1.*)
38
+ Requires-Dist: pyfiglet (>=1.0,<2.0)
39
+ Requires-Dist: python-dateutil (>=2.9,<3.0)
40
+ Requires-Dist: python-dotenv (>=1.2,<2.0)
41
+ Requires-Dist: pytz (==2026.*)
29
42
  Requires-Dist: pyyaml (==6.*)
30
43
  Requires-Dist: requests (>=2.32,<3.0)
31
- Requires-Dist: urllib3 (>=2.3,<3.0)
44
+ Requires-Dist: rich-pyfiglet (>=1.0,<2.0)
45
+ Requires-Dist: ruamel.yaml (==0.*)
46
+ Requires-Dist: urllib3 (>=2.6,<3.0)
32
47
  Requires-Dist: xlrd (>=2.0.1,<2.1.0)
33
- Requires-Dist: xlwings (>=0.33.9,<0.34.0)
48
+ Requires-Dist: xlwings (>=0.35,<1.0)
34
49
  Requires-Dist: xlwt (==1.3.0)
35
50
  Project-URL: Bug Tracker, https://github.com/dmitry-ed-gusev/pyutilities/issues
36
51
  Project-URL: Documentation, https://github.com/dmitry-ed-gusev/pyutilities
@@ -40,8 +55,8 @@ Description-Content-Type: text/markdown
40
55
 
41
56
  # Python Utilities Library
42
57
 
43
- Version 2.1.2, 2018 - 2025, Dmitrii Gusev
44
- *Last update: 28.11.2025*
58
+ Version 2.2.0, 2018 - 2026, Dmitrii Gusev
59
+ *Last update: XX.XX.2026*
45
60
 
46
61
  ## Project Description
47
62
 
@@ -49,6 +64,13 @@ Useful utilities functions for various needs for the python 3.10+. Containing 'g
49
64
 
50
65
  ## Versions history
51
66
 
67
+ ### 2.2.0
68
+
69
+ Added new functions:
70
+
71
+ - func1()
72
+ - func2()
73
+
52
74
  ### 2.1.2
53
75
 
54
76
  Major release with complete set of useful 'general purpose' functions. Documentation 'is coming'...
@@ -1,7 +1,7 @@
1
1
  # Python Utilities Library
2
2
 
3
- Version 2.1.2, 2018 - 2025, Dmitrii Gusev
4
- *Last update: 28.11.2025*
3
+ Version 2.2.0, 2018 - 2026, Dmitrii Gusev
4
+ *Last update: XX.XX.2026*
5
5
 
6
6
  ## Project Description
7
7
 
@@ -9,6 +9,13 @@ Useful utilities functions for various needs for the python 3.10+. Containing 'g
9
9
 
10
10
  ## Versions history
11
11
 
12
+ ### 2.2.0
13
+
14
+ Added new functions:
15
+
16
+ - func1()
17
+ - func2()
18
+
12
19
  ### 2.1.2
13
20
 
14
21
  Major release with complete set of useful 'general purpose' functions. Documentation 'is coming'...
@@ -0,0 +1,315 @@
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, 15.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.4.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 = "docs/README-PUB.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.*",
67
+ "pydantic-settings ==2.*",
68
+ "marshmallow ~=4.1",
69
+ "pyyaml ==6.*",
70
+ "ruamel.yaml ==0.*",
71
+
72
+ # -- technical libraries
73
+ "urllib3~=2.6", # - allowed: >=2.3.0 <3.0.0
74
+ "paramiko==4.*",
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-pyfiglet ~=1.0", # - ASCII graphics addon (colors)
86
+
87
+ # -- datetime utilities
88
+ "pendulum ~=3.2",
89
+ "python-dateutil ~=2.9",
90
+ "pytz ==2026.*"
91
+
92
+ ]
93
+
94
+ # -- additional dependencies groups (test/research/etc. - not runtime)
95
+ [dependency-groups]
96
+
97
+ dev = [
98
+
99
+ # -- pytest library and extensions --
100
+ "pytest ==9.*", # - allowed any version < 10.0.0
101
+ "pytest-env ==1.*",
102
+ "pytest-cov ==7.*",
103
+ "pytest-mock ==3.*",
104
+ "pytest-pep8 ==1.0.6",
105
+ "pytest-flakes ==4.0.5",
106
+ "pytest-isort ==4.0.0",
107
+ "pytest-black ==0.6.0",
108
+ "pytest-variables[hjson,yaml,toml] ==3.1.0",
109
+
110
+ # -- testing-related libraries --
111
+ "mock ==5.*",
112
+ "mockito ~=2",
113
+ "nose2 ==0.*",
114
+ "hypothesis ==6.*",
115
+
116
+ # -- typing libraries + typing stubs for runtime dependencies --
117
+ "mypy ==1.*", # - typing library
118
+ "types-six ==1.*",
119
+ "types-mock ==5.*",
120
+ "types-paramiko ==4.*",
121
+ "types-requests ==2.*",
122
+ "types-markdown ==3.*",
123
+ "types-PyYAML ==6.*",
124
+ "types-flake8-bugbear ==25.*",
125
+
126
+ # -- code quality control libraries
127
+ "flake8 ==7.*",
128
+ "flake8-pyproject ~=1.2",
129
+ "flake8-bandit ~=4.1",
130
+ "flake8-bugbear ==25.*",
131
+ "black ~=26.0", # - code formatter
132
+ "pylint ~=4.0",
133
+ "pre-commit ~=4.0", # - pre-commit hook
134
+ "bandit ==1.9.*",
135
+ "isort[requirements_deprecated_finder,pipfile_deprecated_finder] ==8.*",
136
+ "pyflakes ~=3.4",
137
+ "codeaudit ~=1.4", # - SAST local analysis
138
+
139
+ # -- profiling/debugging libraries
140
+ "snakeviz ==2.2.2",
141
+ "memory-profiler ==0.61.0",
142
+ "py-spy ==0.4.1",
143
+ "viztracer ==1.1.1",
144
+
145
+ # -- development-related process libraries
146
+ "sphinx ==8.* ; python_version == '3.10'", # - docs lib - for python == 3.10
147
+ "sphinx ==9.* ; python_version >= '3.11' and python_version < '4.0'", # - docs lib - for python > 3.10
148
+
149
+ "watchdog ==6.0.0", # - file monitor and auto-reloader
150
+ "responses ==0.*", # - used by many testing/code quality libraries
151
+
152
+ # -- readline module depending on the platform
153
+ "pyreadline3 ==3.5.4 ; sys_platform == 'win32' or sys_platform == 'cygwin'",
154
+ "gnureadline ==8.2.13 ; sys_platform != 'win32'"
155
+
156
+ ]
157
+
158
+ research = [ # - research dependencies (Jupyter, etc.)
159
+
160
+ "notebook~=7.5" # allowed < 8.0.0
161
+
162
+ ]
163
+
164
+ [tool.poetry]
165
+ packages = [{include = "pyutilities", from = "src"}]
166
+
167
+ # -- poetry :: source repositories setup
168
+ [[tool.poetry.source]]
169
+ name = "severstal_repo"
170
+ url = "https://repo.severstal.severstalgroup.com/artifactory/api/pypi/pypi/simple/"
171
+ # priority = "primary" # - primary packages source
172
+ priority = "supplemental" # - packages source will be used when primary is not available...
173
+
174
+ [tool.poetry.dependencies]
175
+ python = ">=3.10,<4"
176
+
177
+ [project.urls]
178
+ Homepage = "https://pypi.org/project/pyutilities"
179
+ Repository = "https://github.com/dmitry-ed-gusev/pyutilities"
180
+ Documentation = "https://github.com/dmitry-ed-gusev/pyutilities"
181
+ "Bug Tracker" = "https://github.com/dmitry-ed-gusev/pyutilities/issues"
182
+
183
+ [project.scripts]
184
+ pyutils = 'pyutilities.cli.pyutils:pyutils'
185
+
186
+ # -- flake8 tool
187
+ [tool.flake8]
188
+ # - list of ignored issues for the flake8 tool
189
+ # - (E501 - long line, F401 - unused import, E203 - whitespace before ':' - black puts it)
190
+ ignore = ['F401']
191
+ # - max cognitive complexity for statements
192
+ max-complexity = 10
193
+ # - line length aligned with same setting for [black] (88 chars by default) -> project value = 110
194
+ max-line-length = 110
195
+ # - ignored violations, specific per files
196
+ per-file-ignores = [
197
+ 'tests/**:S101, S311',
198
+ ]
199
+
200
+ # -- pylint tool
201
+ [tool.pylint.MASTER]
202
+ disable = [
203
+ 'C0114', # missing-module-docstring
204
+ 'C0115', # missing-class-docstring
205
+ 'C0116', # missing-function-docstring
206
+ ]
207
+
208
+ [tool.pylint.FORMAT]
209
+ max-line-length=110
210
+ max-module-lines=1000
211
+
212
+ # -- isort tool
213
+ [tool.isort]
214
+ profile = 'black'
215
+ multi_line_output = 3
216
+ line_length = 110
217
+ include_trailing_comma = true
218
+ skip_gitignore = true
219
+ skip_glob = ["**/migrations/*", "**/settings/*"]
220
+ # src_paths = ["./", "src/"]
221
+ src_paths = ["./src/"]
222
+
223
+ # -- black tool configuration
224
+ [tool.black]
225
+ line_length = 110
226
+ target-version = ['py310']
227
+ extend-exclude = '''
228
+ (
229
+ migrations # Alembic DB migrations
230
+ )
231
+ '''
232
+
233
+ # -- bandit tool
234
+ [tool.bandit]
235
+ exclude_dirs = ["tests"]
236
+ tests = ["B201", "B301"]
237
+ skips = ["B101", "B601"]
238
+
239
+ # -- mypy tool
240
+ [tool.mypy]
241
+ mypy_path = "./"
242
+ python_version = "3.10"
243
+ follow_imports = "silent"
244
+ strict_optional = true
245
+ warn_redundant_casts = true
246
+ warn_unused_ignores = true
247
+ warn_return_any = true
248
+ warn_unused_configs = true
249
+ disallow_any_generics = true
250
+ check_untyped_defs = true
251
+ no_implicit_reexport = true
252
+ allow_untyped_defs = true
253
+ # disallow_untyped_defs = true
254
+ # - mypy will ignore missing types defs imports
255
+ ignore_missing_imports = true
256
+ # - force mypy to analyze as best as its can module without types defs
257
+ follow_untyped_imports = true
258
+
259
+ # [[tool.mypy.overrides]]
260
+ # module = "pyutilities.web.http_client"
261
+ # disable_error_code = ["R0913", "too-many-arguments", "unused-argument"]
262
+
263
+ # -- pytest tool
264
+ [tool.pytest.ini_options]
265
+ minversion = "6.0"
266
+ addopts = """
267
+ --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
268
+
269
+ """
270
+ testpaths = [
271
+ "tests/",
272
+ "integration/",
273
+ ]
274
+ mock_use_standalone_module = true
275
+ mock_traceback_monkeypatch = false
276
+
277
+ # - tests markers - tests can be grouped and executed by them
278
+ markers = [
279
+
280
+ "functional: these tests are significantly slower as they run the whole CLI script",
281
+
282
+ ]
283
+
284
+ # -- env variables for tests in pytest
285
+ [tool.pytest_env]
286
+ # MY_VARIABLE = "my_value"
287
+ PYTHONTRACEMALLOC = 20
288
+
289
+ # -- coverage tool configuration (coveragerc)
290
+ [tool.coverage.run]
291
+ branch = true
292
+ data_file = ".coverage/.coverage"
293
+ omit = [
294
+ '*__init__*',
295
+ '*temp*',
296
+ '*tests\*'
297
+ ]
298
+
299
+ [tool.coverage.report]
300
+ show_missing = true
301
+ # - show 2 decimal digits for coverage report values
302
+ precision = 2
303
+ # skip_covered = true
304
+
305
+ [tool.coverage.html]
306
+ directory = ".coverage/htmlcoverage"
307
+ title = "Python Utilities :: Tests Coverage Report."
308
+
309
+ [tool.coverage.xml]
310
+ output = ".coverage/coverage.xml"
311
+
312
+ # -- this setting is used by coverage.py, ignored by pytest-cov
313
+ [tool.coverage.json]
314
+ output = ".coverage/coverage.json"
315
+ pretty_print = true
@@ -1,3 +1,5 @@
1
+ # -*- coding: utf-8 -*-
2
+
1
3
  # This code should be put in <your_package_name>/__init__.py or <your_package_name>/_version.py
2
4
  # The library version now is programmatically accessible (from code).
3
5
 
@@ -0,0 +1,28 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ """
4
+ Cmd line module for th pyutilities library - integration with CLI.
5
+
6
+ Created: Dmitrii Gusev, 17.04.2026
7
+ Modified: Dmitrii Gusev, 17.04.2026
8
+ """
9
+
10
+ import click
11
+
12
+ from pyutilities import __version__
13
+
14
+ MSG_VERSION = f"\nPy Utilities, version: {__version__}, (C) Dmitrii Gusev, 2018-2026.\n"
15
+
16
+
17
+ @click.group()
18
+ @click.help_option("-h", "--help")
19
+ @click.version_option(__version__, "-v", "--version", message=MSG_VERSION)
20
+ @click.pass_context
21
+ def pyutils(ctx): # pylint: disable=unused-argument
22
+ """Module [Py Utilities], (C) Dmitrii Gusev, 2018-2026."""
23
+ click.echo("")
24
+
25
+
26
+ @pyutils.command("version")
27
+ def version():
28
+ click.echo(__version__ + "\n")
@@ -321,7 +321,8 @@ class ConfigurationXls(Configuration):
321
321
  dictionary[name] = value
322
322
 
323
323
  elif path_to_xls.endswith("xlsx"): # load from excel file - format xlsx
324
- excel_book = openpyxl.load_workbook(path_to_xls) # workbook
324
+ # load workbook by the given path
325
+ excel_book = openpyxl.load_workbook(path_to_xls) # type: ignore
325
326
  excel_sheet = excel_book[config_sheet_name] # specified sheet by name
326
327
  self.log.debug("Loaded XLSX config. Found [%s] row(s). Loading.", excel_sheet.max_row)
327
328
  for rownumber in range(excel_sheet.max_row):
@@ -4,7 +4,7 @@
4
4
  IO Utilities module.
5
5
 
6
6
  Created: Dmitrii Gusev, 04.04.2017
7
- Modified: Dmitrii Gusev, 25.11.2025
7
+ Modified: Dmitrii Gusev, 17.04.2026
8
8
  """
9
9
 
10
10
  import errno
@@ -83,7 +83,7 @@ def str_2_file(filename: str, content: str, overwrite: bool = False, encoding: s
83
83
  f.write(content)
84
84
 
85
85
 
86
- def file2str(filename: str, encoding: str = DEFAULT_ENCODING) -> str:
86
+ def file_2_str(filename: str, encoding: str = DEFAULT_ENCODING) -> str:
87
87
  """Read content from the provided file as string/text."""
88
88
 
89
89
  log.debug("file2str(): reading content from file: [%s].", filename)
@@ -123,8 +123,20 @@ def compress_file(input_file, output_file):
123
123
  shutil.copyfileobj(f_in, f_out)
124
124
 
125
125
 
126
- def file_size(file_path: str) -> str:
127
- """Function will return the file size in readable format with the highest size mark - KB/MB/GB/TB."""
126
+ def file_str(file_path: str) -> int:
127
+ """Function will return the file size in bytes. In case file doesn't exist/not a file/other
128
+ issues - the function will return -1 (negative value)."""
129
+
130
+ if os.path.isfile(file_path):
131
+ file_info = os.stat(file_path)
132
+ return file_info.st_size
133
+
134
+ return -1
135
+
136
+
137
+ def file_size_str(file_path: str) -> str:
138
+ """Function will return the file size in a human-readable format with the highest size
139
+ mark - KB/MB/GB/TB."""
128
140
 
129
141
  if os.path.isfile(file_path):
130
142
  file_info = os.stat(file_path)