relib 1.3.3__py3-none-any.whl → 1.3.4__py3-none-any.whl

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.
relib/io_utils.py CHANGED
@@ -1,8 +1,10 @@
1
1
  import json
2
2
  from pathlib import Path
3
- from typing import Any
3
+ from typing import Any, Iterable
4
4
 
5
5
  __all__ = [
6
+ "clear_directory",
7
+ "empty_dirs",
6
8
  "read_json",
7
9
  "write_json",
8
10
  ]
@@ -19,3 +21,21 @@ def write_json(path: Path, obj: object, indent: None | int = None) -> None:
19
21
  with path.open("w") as f:
20
22
  separators = (",", ":") if indent is None else None
21
23
  return json.dump(obj, f, indent=indent, separators=separators)
24
+
25
+ def empty_dirs(path: Path) -> Iterable[Path]:
26
+ nonempty_count = 0
27
+ for child in path.iterdir():
28
+ nonempty_count += 1
29
+ if child.is_dir():
30
+ for grand_child in empty_dirs(child):
31
+ yield grand_child
32
+ nonempty_count -= child == grand_child
33
+ if nonempty_count == 0:
34
+ yield path
35
+
36
+ def clear_directory(path: Path):
37
+ if path.is_dir():
38
+ for file in path.glob("**/.DS_Store"):
39
+ file.unlink()
40
+ for directory in empty_dirs(path):
41
+ directory.rmdir()
relib/runtime_tools.py CHANGED
@@ -25,7 +25,7 @@ default_executor = ThreadPoolExecutor(max_workers=default_workers)
25
25
 
26
26
  def raise_if_interrupt():
27
27
  if sys.exc_info()[0] in (KeyboardInterrupt, SystemExit):
28
- raise
28
+ raise
29
29
 
30
30
  def clear_console() -> None:
31
31
  os.system("cls" if os.name == "nt" else "clear")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: relib
3
- Version: 1.3.3
3
+ Version: 1.3.4
4
4
  Project-URL: Repository, https://github.com/Reddan/relib.git
5
5
  Author: Hampus Hallman
6
6
  License: Copyright 2018-2025 Hampus Hallman
@@ -1,11 +1,11 @@
1
1
  relib/__init__.py,sha256=WerjUaM_sNvudjXFudLRtXB7viZWEW1RSinkDjrh4nE,163
2
2
  relib/dict_utils.py,sha256=jqW6bYSaQMt2AC2KFzDJKyl88idyMttWxXDu3t-fA5I,2980
3
- relib/io_utils.py,sha256=EtnIGQmLXjoHUPFteB5yPXDD3wGLvH4O3CahlCebXDQ,555
3
+ relib/io_utils.py,sha256=cUyUFhrMCUDfkINhYo32QPaVGz3chqDO3ElymSCoWEg,1086
4
4
  relib/iter_utils.py,sha256=r9tus9F_obwXsHE8Jk8H9_ZPdOgtBI6WnpDxI6La-to,5477
5
5
  relib/processing_utils.py,sha256=eMzjlxsEmfvtKafDITBWSp9D5RwegSWsUsvj1FpmBM0,1893
6
- relib/runtime_tools.py,sha256=9N8gn3WCfqyS6D3Qs4l2nDja_NxDVVF-7hHIVrXA7Fc,2968
6
+ relib/runtime_tools.py,sha256=Bb0OLMNgG9sqJpMc06x_W5aJNfJ2Z0ryc8f4WEP7Pz4,2967
7
7
  relib/type_utils.py,sha256=oY96cAAux1JwhXgWFFyqEv_f-wwyPc_Hm6I9Yeisu_M,323
8
- relib-1.3.3.dist-info/METADATA,sha256=3z1-dTnOlkjYiy54JQ2VQOs0zy5_kyP4Bk33l1YuAoQ,1295
9
- relib-1.3.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
10
- relib-1.3.3.dist-info/licenses/LICENSE,sha256=9xVsdtv_-uSyY9Xl9yujwAPm4-mjcCLeVy-ljwXEWbo,1059
11
- relib-1.3.3.dist-info/RECORD,,
8
+ relib-1.3.4.dist-info/METADATA,sha256=VSsdKCUxM9Q_qR9xFV1bzaGR8GPv3Unm9a05RzzHGzQ,1295
9
+ relib-1.3.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
10
+ relib-1.3.4.dist-info/licenses/LICENSE,sha256=9xVsdtv_-uSyY9Xl9yujwAPm4-mjcCLeVy-ljwXEWbo,1059
11
+ relib-1.3.4.dist-info/RECORD,,
File without changes