utils-mystuff 1.1.0__tar.gz → 1.2.1__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.
@@ -1,3 +1,4 @@
1
1
  # Contributors
2
2
 
3
3
  * [dornech](https://github.com/dornech)
4
+ * [maresb](https://github.com/maresb)
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.5
2
2
  Name: utils-mystuff
3
- Version: 1.1.0
3
+ Version: 1.2.1
4
4
  Summary: Package with various utilities i.e. VB regex translation, CLI logging, file handling, basic GUI wrapper ...
5
5
  Project-URL: Documentation, https://dornech.github.io/utils-mystuff
6
6
  Project-URL: Source, https://github.com/dornech/utils-mystuff
@@ -10,22 +10,22 @@ Author-email: dornech <dornech@gmx.de>
10
10
  License: GPL-3.0-only
11
11
  License-File: AUTHORS.md
12
12
  License-File: LICENSE.txt
13
- Keywords: CLI logging,GUI wrapper,RegEx conversion,command line interface,file handling,logging,regular expression
13
+ Keywords: CLI logging,GUI wrapper,RegEx conversion,command line interface,config file reader,config parser,file handling,logger creartion,logging,regular expression
14
14
  Classifier: Programming Language :: Python
15
- Classifier: Programming Language :: Python :: 3.10
16
15
  Classifier: Programming Language :: Python :: 3.11
17
16
  Classifier: Programming Language :: Python :: 3.12
18
17
  Classifier: Programming Language :: Python :: 3.13
19
18
  Classifier: Programming Language :: Python :: 3.14
20
19
  Classifier: Programming Language :: Python :: Implementation :: CPython
21
- Requires-Python: >=3.10
20
+ Requires-Python: >=3.11
22
21
  Requires-Dist: easygui
23
22
  Requires-Dist: freesimplegui
24
23
  Requires-Dist: pymsgbox
25
24
  Requires-Dist: python-dateutil
26
25
  Requires-Dist: pytz
27
- Provides-Extra: python39
28
- Requires-Dist: typing-extensions; extra == 'python39'
26
+ Provides-Extra: vcs-version
27
+ Requires-Dist: hatch-vcs; extra == 'vcs-version'
28
+ Requires-Dist: hatchling; extra == 'vcs-version'
29
29
  Description-Content-Type: text/markdown
30
30
 
31
31
  # Personal utilities package for Python
@@ -48,6 +48,10 @@ method stubs (at least for most important subroutines) as a compromise.
48
48
 
49
49
  ## Development
50
50
 
51
+ `utils_mystuff.__version__` reads the version recorded at installation. To have an editable
52
+ installation follow new Git tags without reinstalling, run `python -m pip install -e '.[vcs-version]'`
53
+ in the checkout and set `UTILS_MYSTUFF_HATCH_VCS_RUNTIME_VERSION=1` in that development environment.
54
+
51
55
  To set up [hatch] and [pre-commit] for the first time:
52
56
 
53
57
  1. install [hatch] globally, e.g. with [pipx], i.e. `pipx install hatch`,
@@ -18,6 +18,10 @@ method stubs (at least for most important subroutines) as a compromise.
18
18
 
19
19
  ## Development
20
20
 
21
+ `utils_mystuff.__version__` reads the version recorded at installation. To have an editable
22
+ installation follow new Git tags without reinstalling, run `python -m pip install -e '.[vcs-version]'`
23
+ in the checkout and set `UTILS_MYSTUFF_HATCH_VCS_RUNTIME_VERSION=1` in that development environment.
24
+
21
25
  To set up [hatch] and [pre-commit] for the first time:
22
26
 
23
27
  1. install [hatch] globally, e.g. with [pipx], i.e. `pipx install hatch`,
@@ -15,14 +15,15 @@ build-backend = "hatchling.build"
15
15
  name = "utils-mystuff"
16
16
  description = "Package with various utilities i.e. VB regex translation, CLI logging, file handling, basic GUI wrapper ..."
17
17
  readme = "README.md"
18
- requires-python = ">=3.10"
18
+ requires-python = ">=3.11"
19
19
  # only license identifier from https://spdx.org/licenses/ are allowed
20
20
  license = { text = "GPL-3.0-only" }
21
21
  # keywords for easier look-up on PyPI
22
22
  keywords = [
23
23
  "RegEx conversion", "regular expression",
24
- "command line interface", "CLI logging", "logging",
25
- "GUI wrapper", "file handling"
24
+ "command line interface", "CLI logging", "logging", "logger creartion",
25
+ "config file reader", "config parser",
26
+ "GUI wrapper", "file handling",
26
27
  ]
27
28
  authors = [
28
29
  { name = "dornech", email = "dornech@gmx.de" },
@@ -30,7 +31,6 @@ authors = [
30
31
  # options under https://pypi.org/classifiers/
31
32
  classifiers = [
32
33
  "Programming Language :: Python",
33
- "Programming Language :: Python :: 3.10",
34
34
  "Programming Language :: Python :: 3.11",
35
35
  "Programming Language :: Python :: 3.12",
36
36
  "Programming Language :: Python :: 3.13",
@@ -40,17 +40,15 @@ classifiers = [
40
40
  # direct dependencies of this package, installed when users `pip install utils-mystuff` later.
41
41
  dependencies = [
42
42
  "easygui",
43
- "freesimplegui",
44
- "python_dateutil",
43
+ "FreeSimpleGUI",
44
+ "python-dateutil",
45
45
  "pytz",
46
- "pymsgbox"
46
+ "pymsgbox",
47
47
  ]
48
48
  dynamic = ["version"]
49
49
 
50
50
  [project.optional-dependencies]
51
- python39 = [
52
- "typing-extensions",
53
- ]
51
+ vcs-version = ["hatchling", "hatch-vcs"]
54
52
 
55
53
  [project.scripts]
56
54
  # n. a.
@@ -93,7 +91,7 @@ exclude = [
93
91
  [tool.commitizen]
94
92
  name = "cz_customize"
95
93
  version_scheme = "pep440"
96
- version = "1.1.0"
94
+ version = "1.2.1"
97
95
  version_files = ["pyproject.toml:version"]
98
96
  tag_format = "v$version"
99
97
  # retry_after_failure = false
@@ -120,8 +118,8 @@ bump_map = {"feat" = "MINOR", "fix" = "PATCH", "BREAKING CHANGE" = "MAJOR"}
120
118
  # with Initial Commit in changelog
121
119
  commit_parser ="^(?P<change_type>[Ii]nitial [Cc]ommit|feat|fix|refactor|perf|docs|style|test|chore|build|ci|revert|BREAKING CHANGE)(\\((?P<scope>[^)]+)\\))?(:\\s(?P<message>.*))?"
122
120
  changelog_pattern = "^([Ii]nitial [Cc]ommit|feat|fix|docs|style|refactor|perf|test|chore|build|ci|revert|BREAKING CHANGE).*"
123
- change_type_map = { feat = "Features", fix = "Bug fixes", refactor = "Refactoring", perf = "performance improvements", docs = "Documentation", style = "Code style", test = "Testing", chore = "Chores", build = "Build system", ci = "Continuous Integration" }
124
- change_type_order = ["BREAKING CHANGE", "feat", "fix", "refactor", "perf", "docs", "style", "test", "chore", "build", "ci"]
121
+ change_type_map = { feat = "Features", fix = "Bug fixes", refactor = "Code refactoring", perf = "Performance improvements", docs = "Documentation", style = "Code style", test = "Testing", chore = "Chores", build = "Build system", ci = "Continuous Integration" }
122
+ change_type_order = ["BREAKING CHANGE", "Features", "Bug fixes", "Code refactoring", "Performance improvements", "Documentation", "Code style", "Testing", "Chore", "Build System", "Continuous Integration", "Initial Commit"]
125
123
 
126
124
 
127
125
  ##################
@@ -140,7 +138,7 @@ ignore-args = false
140
138
  ignore-kwargs = false
141
139
  ignore-no-params = true
142
140
  ignore_typechecker= false
143
- # disable = []
141
+ disable = ["SIG305", "SIG306"]
144
142
  # target = []
145
143
 
146
144
  [tool.ruff]
@@ -151,8 +149,9 @@ include = [
151
149
  "src/**/*.py",
152
150
  "src/**/*.pyi",
153
151
  "tests/**/*.py",
154
- "tests/**/*.pyi"
152
+ "tests/**/*.pyi",
155
153
  ]
154
+ output-prefer-rule-codes = true
156
155
 
157
156
  [tool.ruff.lint]
158
157
  preview = true # preview features & checks, use with caution
@@ -247,6 +246,23 @@ warn_unused_ignores = true
247
246
  warn_return_any = true
248
247
  warn_unused_configs = true
249
248
 
249
+ [tool.deptry]
250
+ known_first_party = ["utils_mystuff"]
251
+ exclude = ["docs", "tests"]
252
+ ignore_notebooks = true
253
+ github_output = true
254
+ github_warning_errors = ["DEP003"]
255
+
256
+ [tool.deptry.package_module_name_map]
257
+ easygui = "easygui"
258
+ FreeSimpleGUI = "FreeSimpleGUI"
259
+ pymsgbox = "pymsgbox"
260
+ python-dateutil = "dateutil"
261
+
262
+ [tool.deptry.per_rule_ignores]
263
+ # hatch-vcs is loaded through Hatchling's version source entry point.
264
+ DEP002 = ["easygui", "FreeSimpleGUI", "pymsgbox", "hatch-vcs"]
265
+
250
266
  [tool.cruft]
251
267
  skip = ["README.md", "CHANGELOG.MD", "src/", "tests/", "docs/", "notebooks/"]
252
268
 
@@ -256,6 +272,10 @@ addopts = "-ra -q --doctest-glob='*.md'"
256
272
  testpaths = [
257
273
  "tests",
258
274
  ]
275
+ markers = [
276
+ "integration: integration test cases",
277
+ "local: test cases not suitable for CI",
278
+ ]
259
279
 
260
280
  [tool.coverage.run]
261
281
  branch = true
@@ -302,21 +322,24 @@ dependencies = [
302
322
  ]
303
323
  # installer = "pip"
304
324
 
305
- # Hatch default test environment for "hatch test" (also used in GitAction)
325
+ # Hatch default test environment for "hatch test" (also used in GitHub Action)
326
+ # do not define scripts [tool.hatch.envs.hatch-test.scripts] without taking over hatch standard scripts!!!
306
327
  [tool.hatch.envs.hatch-test]
328
+ features = ["vcs-version"]
307
329
  dependencies = [
308
330
  "pip",
309
331
  "coverage-enable-subprocess==1.0",
310
- "coverage[toml]~=7.4",
311
- "pytest~=8.1",
312
- "pytest-mock~=3.12",
313
- "pytest-randomly~=3.15",
314
- "pytest-rerunfailures~=14.0",
315
- "pytest-xdist[psutil]~=3.5",
332
+ "coverage[toml]>=7.4",
333
+ "pytest>=8.1",
334
+ "pytest-mock>=3.12",
335
+ "pytest-randomly>=3.15",
336
+ "pytest-rerunfailures>=14.0",
337
+ "pytest-xdist[psutil]>=3.5",
316
338
  ]
317
339
 
318
- # Test environment with test-only dependencies (do not mix up with default hatch-test environment "hatch-test" !)
340
+ # Hatch local testing environment with test-only dependencies (do not mix up with default hatch-test environment "hatch-test" !)
319
341
  [tool.hatch.envs.test]
342
+ features = ["vcs-version"]
320
343
  dependencies = [
321
344
  # required test dependencies
322
345
  "pip",
@@ -332,28 +355,30 @@ dependencies = [
332
355
  cov = "pytest --cov-report=term-missing --cov-config=pyproject.toml --cov=src/utils_mystuff --cov=tests {args}"
333
356
  no-cov = "cov --no-cov {args}"
334
357
  debug = "cov --no-cov -s --pdb --pdbcls=IPython.core.debugger:Pdb {args}"
358
+ test_not_local_only = "run pytest -m 'not local'"
359
+ test_local_only = "run pytest -m 'local'"
335
360
 
336
- # Hatch testing environment matrix for various Python versions replacing the functionality of tox
361
+ # Hatch local testing environment matrix for various Python versions replacing the functionality of tox
337
362
  [[tool.hatch.envs.test.matrix]]
338
363
  template = ["test"]
339
- python = ["3.10", "3.11", "3.12", "3.13", "3.14"]
364
+ python = ["3.11", "3.12", "3.13", "3.14"]
340
365
 
341
366
  # Hatch default linting environment for "hatch fmt"
342
367
  [tool.hatch.envs.hatch-static-analysis]
343
368
  dependencies = [
344
369
  "pip",
345
- "mypy==1.16.0",
346
- "ruff==0.11.12",
370
+ "mypy==2.3.0",
371
+ "ruff==0.16.2",
347
372
  ]
348
373
 
349
- # Hatch Linting environment for GitAction
374
+ # Hatch Linting environment for GitHub Action
350
375
  [tool.hatch.envs.lint]
351
376
  template = "lint" # don't inherit from default!
352
377
  dependencies = [
353
378
  "pip",
354
- "mypy==1.16.0",
355
- "ruff==0.11.12",
356
- "docsig==0.71.0",
379
+ "mypy==2.3.0",
380
+ "ruff==0.16.2",
381
+ "docsig==0.94.0",
357
382
  ]
358
383
  [tool.hatch.envs.lint.scripts]
359
384
  typing = [
@@ -49,7 +49,7 @@ Example / doctest (note escaping in output to avoid error):
49
49
  # boolean-type arguments
50
50
  # ruff: noqa: FBT001, FBT002, Q003
51
51
  # others
52
- # ruff: noqa: E501
52
+ # ruff: noqa: E501, RUF105
53
53
 
54
54
  # fmt: off
55
55
 
@@ -13,7 +13,7 @@ parsed arguments structure.
13
13
  # naming conventions
14
14
  # ruff: noqa: N801, N802, N803, N806, N812, N813, N815, N816, N818, N999
15
15
  # others
16
- # ruff: noqa: E115, E501, RUF059, SIM102
16
+ # ruff: noqa: E115, E501, RUF059, RUF105, SIM102
17
17
  #
18
18
  # disable mypy errors
19
19
  # - mypy error "'object' has no attribute 'xyz' [attr-defined]" when accessing attributes of
@@ -48,7 +48,7 @@ True
48
48
  # boolean-type arguments
49
49
  # ruff: noqa: FBT001, FBT002
50
50
  # others
51
- # ruff: noqa: B006, E501, F841, PLW3301, RUF022
51
+ # ruff: noqa: B006, E501, F841, PLW3301, RUF022, RUF105
52
52
  #
53
53
  # disable mypy errors
54
54
  # - errors occur when attributes of dynamically (re)loaded module(s)
@@ -12,12 +12,13 @@ Module contains filesystem related utilities.
12
12
  # naming conventions
13
13
  # ruff: noqa: N801, N802, N803, N806, N812, N813, N815, N816, N818, N999
14
14
  # others
15
- # ruff: noqa: E501, PLR1702, PLW1514, SIM102, SIM115, TID252, UP015
15
+ # ruff: noqa: E501, PLR1702, PLW1514, RUF105, SIM102, SIM115, TID252, UP015
16
16
 
17
17
  # fmt: off
18
18
 
19
19
 
20
20
 
21
+ import glob
21
22
  import os
22
23
  import fnmatch
23
24
  import datetime
@@ -74,7 +75,7 @@ def is_file_locked(filepath: str, waittime: float = 0.1) -> bool:
74
75
 
75
76
 
76
77
  # wait for file with timeout
77
- # aproaches here: https://stackoverflow.com/questions/54487381/check-for-a-files-availability-for-a-certain-time-and-then-break
78
+ # approaches here: https://stackoverflow.com/questions/54487381/check-for-a-files-availability-for-a-certain-time-and-then-break
78
79
  def wait_for_file(filepath: str, timeout: int = 5, waittime: float = 0.1) -> bool:
79
80
  """
80
81
  wait_for_file - wait until file is available or timeout
@@ -101,6 +102,63 @@ def wait_for_file(filepath: str, timeout: int = 5, waittime: float = 0.1) -> boo
101
102
  return file_exists
102
103
 
103
104
 
105
+ def wait_for_file_with_wildcard(filepath: str, timeout: float = 5, waittime: float = 0.1) -> str | None:
106
+ """
107
+ wait_for_file_with_wildcard - wait until file is available or timeout
108
+
109
+ Args:
110
+ filepath (str): filepath with wildcard to be checked
111
+ timeout (int): timeout period
112
+ waittime (float): waittime between two checks
113
+
114
+ Returns:
115
+ str: first found filename if found, otherwise None
116
+ """
117
+
118
+ start_time = time.time()
119
+ files = None
120
+
121
+ while not files:
122
+ time.sleep(waittime)
123
+ files = glob.glob(filepath)
124
+ if files:
125
+ return files[0]
126
+ elapsed_time = time.time() - start_time
127
+ if timeout > 0 and elapsed_time >= timeout:
128
+ break
129
+
130
+ return None
131
+
132
+
133
+ def wait_for_file_out_of_list(filepaths: list[str], timeout: float = 5, waittime: float = 0.1) -> str | None:
134
+ """
135
+ wait_for_file_out_of_list - wait for file out of list
136
+
137
+ Args:
138
+ filepaths (str): list of filepaths to be checked
139
+ timeout (int): timeout period
140
+ waittime (float): waittime between two checks
141
+
142
+ Returns:
143
+ str: first found filename if found, otherwise None
144
+ """
145
+
146
+ start_time = time.time()
147
+ file = None
148
+
149
+ while not file:
150
+ time.sleep(waittime)
151
+ for filepath in filepaths:
152
+ file = wait_for_file_with_wildcard(filepath, timeout=0.1, waittime=0.1)
153
+ if file:
154
+ return file
155
+ elapsed_time = time.time() - start_time
156
+ if timeout > 0 and elapsed_time >= timeout:
157
+ break
158
+
159
+ return None
160
+
161
+
104
162
  # find latest changed file in searchpath matching filename pattern provided as searchpattern
105
163
  # timestamp referring to nanoseconds timestamp from filesystem, otherwise problems in rare cases
106
164
  # (1 second resolution not sufficient)
@@ -135,7 +193,7 @@ def find_last_changed_file(
135
193
  while (lastchangedfile == "") and (datetime.datetime.now(dateutil.tz.tz.tzlocal()) <= timenow + datetime.timedelta(seconds=timeout_sec)):
136
194
 
137
195
  with os.scandir(searchpath) as searchpathscan:
138
- scanentry: os.DirEntry # overcome PyCharm IDE error - workaround derived from https://youtrack.jetbrains.com/issue/PY-46041
196
+ scanentry: os.DirEntry # overcome PyCharm IDE error - workaround derived from https://youtrack.jetbrains.com/issue/PY-46041
139
197
  for scanentry in searchpathscan:
140
198
  if fnmatch.fnmatch(scanentry.name, searchpattern):
141
199
  filemodified = scanentry.stat().st_mtime_ns / 1000000000
@@ -14,7 +14,7 @@ Module contains a collection of miscellaneous utilities.
14
14
  # boolean-type arguments
15
15
  # ruff: noqa: FBT001, FBT002, S101
16
16
  # others
17
- # ruff: noqa: B006, B905, DTZ007, E501, PLW0602, SIM102, SIM105, UP007, UP045
17
+ # ruff: noqa: B006, B905, DTZ007, E501, PLW0602, RUF105, SIM102, SIM105, UP007, UP045
18
18
  #
19
19
  # disable mypy errors
20
20
  # mypy: disable-error-code = "unused-ignore"
@@ -25,13 +25,8 @@ Module contains a collection of miscellaneous utilities.
25
25
 
26
26
 
27
27
 
28
- from typing import Any, TypeVar
28
+ from typing import Any, ParamSpec, TypeVar
29
29
  from collections.abc import Callable
30
- # importing ParamSpec in backwards compatible way
31
- try:
32
- from typing import ParamSpec # type: ignore
33
- except ImportError:
34
- from typing_extensions import ParamSpec # type: ignore
35
30
 
36
31
  import sys
37
32
  import os
@@ -0,0 +1,44 @@
1
+ """Read the installed version, with optional VCS lookup for editable installs.
2
+
3
+ Based on <https://github.com/maresb/hatch-vcs-footgun-example>.
4
+ """
5
+
6
+
7
+ # ruff and mypy per file settings
8
+ # others
9
+ # ruff: noqa: E303, RUF105
10
+
11
+ # fmt: off
12
+
13
+
14
+
15
+ import os
16
+ from contextlib import chdir
17
+ from importlib.metadata import version
18
+ from pathlib import Path
19
+
20
+
21
+
22
+ def _get_hatch_version():
23
+ """Read the checkout's version using Hatch and its configured version source."""
24
+
25
+ from hatchling.metadata.core import ProjectMetadata # ruff: ignore[import-outside-top-level]
26
+ from hatchling.plugin.manager import PluginManager # ruff: ignore[import-outside-top-level]
27
+ from hatchling.utils.fs import locate_file # ruff: ignore[import-outside-top-level]
28
+
29
+ pyproject_toml = locate_file(__file__, "pyproject.toml")
30
+ if pyproject_toml is None:
31
+ msg = "UTILS_MYSTUFF_HATCH_VCS_RUNTIME_VERSION requires a utils-mystuff source checkout"
32
+ raise RuntimeError(msg)
33
+
34
+ # Hatch metadata hooks expect to run from the project root.
35
+ root = Path(pyproject_toml).parent
36
+ with chdir(root):
37
+ metadata = ProjectMetadata(root=str(root), plugin_manager=PluginManager())
38
+ return metadata.core.version or metadata.hatch.version.cached
39
+
40
+
41
+ if os.environ.get("UTILS_MYSTUFF_HATCH_VCS_RUNTIME_VERSION"):
42
+ __version__ = _get_hatch_version()
43
+ else:
44
+ __version__ = version("utils-mystuff")
@@ -1,55 +0,0 @@
1
- """Compute the version number and store it in the `__version__` variable.
2
-
3
- Based on <https://github.com/maresb/hatch-vcs-footgun-example>.
4
- """
5
-
6
-
7
- # ruff and mypy per file settings
8
- # others
9
- # ruff: noqa: PLC0415
10
-
11
- # fmt: off
12
-
13
-
14
- def _get_hatch_version():
15
- """Compute the most up-to-date version number in a development environment.
16
-
17
- Returns `None` if Hatchling is not installed, e.g. in a production environment.
18
-
19
- For more details, see <https://github.com/maresb/hatch-vcs-footgun-example/>.
20
- """
21
- import os
22
-
23
- try:
24
- from hatchling.metadata.core import ProjectMetadata
25
- from hatchling.plugin.manager import PluginManager
26
- from hatchling.utils.fs import locate_file
27
- except ImportError:
28
- # Hatchling is not installed, so probably we are not in a development environment.
29
- return None
30
-
31
- pyproject_toml = locate_file(__file__, "pyproject.toml")
32
- if pyproject_toml is None:
33
- err_msg = "pyproject.toml not found although hatchling is installed"
34
- raise RuntimeError(err_msg)
35
- root = os.path.dirname(pyproject_toml)
36
- metadata = ProjectMetadata(root=root, plugin_manager=PluginManager())
37
- # Version can be either statically set in pyproject.toml or computed dynamically:
38
- return metadata.core.version or metadata.hatch.version.cached
39
-
40
-
41
- def _get_importlib_metadata_version():
42
- """Compute the version number using importlib.metadata.
43
-
44
- This is the official Pythonic way to get the version number of an installed
45
- package. However, it is only updated when a package is installed. Thus, if a
46
- package is installed in editable mode, and a different version is checked out,
47
- then the version number will not be updated.
48
- """
49
- from importlib.metadata import version
50
-
51
- __version__ = version(__package__)
52
- return __version__
53
-
54
-
55
- __version__ = _get_hatch_version() or _get_importlib_metadata_version()
File without changes
File without changes