relib 1.3.2__tar.gz → 1.3.4__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,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: relib
3
- Version: 1.3.2
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,6 +1,6 @@
1
1
  [project]
2
2
  name = "relib"
3
- version = "1.3.2"
3
+ version = "1.3.4"
4
4
  requires-python = ">=3.12"
5
5
  dependencies = []
6
6
  authors = [
@@ -16,6 +16,7 @@ Repository = "https://github.com/Reddan/relib.git"
16
16
  [dependency-groups]
17
17
  dev = [
18
18
  "numpy>=2.1.3",
19
+ "omg>=1.3.6",
19
20
  "pandas>=2.2.3",
20
21
  "tqdm>=4.67.1",
21
22
  ]
@@ -0,0 +1,41 @@
1
+ import json
2
+ from pathlib import Path
3
+ from typing import Any, Iterable
4
+
5
+ __all__ = [
6
+ "clear_directory",
7
+ "empty_dirs",
8
+ "read_json",
9
+ "write_json",
10
+ ]
11
+
12
+ default_sentinel = object()
13
+
14
+ def read_json(path: Path, default=default_sentinel) -> Any:
15
+ if default is not default_sentinel and not path.exists():
16
+ return default
17
+ with path.open("r") as f:
18
+ return json.load(f)
19
+
20
+ def write_json(path: Path, obj: object, indent: None | int = None) -> None:
21
+ with path.open("w") as f:
22
+ separators = (",", ":") if indent is None else None
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()
@@ -10,6 +10,7 @@ __all__ = [
10
10
  "interleave", "intersect",
11
11
  "list_split",
12
12
  "move_value",
13
+ "partition",
13
14
  "reversed_enumerate",
14
15
  "seekable", "sort_by",
15
16
  "transpose",
@@ -51,6 +52,15 @@ def list_split[T](iterable: Iterable[T], sep: T) -> list[list[T]]:
51
52
  ranges = list(zip(split_at[0:-1], split_at[1:]))
52
53
  return [values[start + 1:end] for start, end in ranges]
53
54
 
55
+ def partition[T](iterable: Iterable[tuple[bool, T]]) -> tuple[list[T], list[T]]:
56
+ true_values, false_values = [], []
57
+ for predicate, value in iterable:
58
+ if predicate:
59
+ true_values.append(value)
60
+ else:
61
+ false_values.append(value)
62
+ return true_values, false_values
63
+
54
64
  class seekable[T]:
55
65
  def __init__(self, iterable: Iterable[T]):
56
66
  self.index = 0
@@ -1,6 +1,7 @@
1
1
  import asyncio
2
2
  import contextvars
3
3
  import os
4
+ import sys
4
5
  from concurrent.futures import ThreadPoolExecutor
5
6
  from functools import partial, wraps
6
7
  from time import time
@@ -11,7 +12,7 @@ __all__ = [
11
12
  "as_async", "async_limit",
12
13
  "clear_console", "console_link",
13
14
  "default_executor", "default_workers",
14
- "roll_tasks",
15
+ "raise_if_interrupt", "roll_tasks",
15
16
  "measure_duration",
16
17
  ]
17
18
 
@@ -22,6 +23,10 @@ Coro = Coroutine[object, object, R]
22
23
  default_workers = min(32, (os.cpu_count() or 1) + 4)
23
24
  default_executor = ThreadPoolExecutor(max_workers=default_workers)
24
25
 
26
+ def raise_if_interrupt():
27
+ if sys.exc_info()[0] in (KeyboardInterrupt, SystemExit):
28
+ raise
29
+
25
30
  def clear_console() -> None:
26
31
  os.system("cls" if os.name == "nt" else "clear")
27
32
 
@@ -49,6 +49,18 @@ wheels = [
49
49
  { url = "https://files.pythonhosted.org/packages/86/09/a5ab407bd7f5f5599e6a9261f964ace03a73e7c6928de906981c31c38082/numpy-2.1.3-cp313-cp313t-win_amd64.whl", hash = "sha256:2564fbdf2b99b3f815f2107c1bbc93e2de8ee655a69c261363a1172a79a257d4", size = 12644098 },
50
50
  ]
51
51
 
52
+ [[package]]
53
+ name = "omg"
54
+ version = "1.3.6"
55
+ source = { registry = "https://pypi.org/simple" }
56
+ dependencies = [
57
+ { name = "watchdog" },
58
+ ]
59
+ sdist = { url = "https://files.pythonhosted.org/packages/65/06/da0a3778b7ff8f1333ed7ddc0931ffff3c86ab5cb8bc4a96a1d0edb8671b/omg-1.3.6.tar.gz", hash = "sha256:465a51b7576fa31ef313e2b9a77d57f5d4816fb0a14dca0fc5c09ff471074fe6", size = 14268 }
60
+ wheels = [
61
+ { url = "https://files.pythonhosted.org/packages/dd/d2/87346e94dbecd3a65a09e2156c1adf30c162f31e69d0936343c3eff53e7a/omg-1.3.6-py3-none-any.whl", hash = "sha256:8e3ac99a18d5284ceef2ed98492d288d5f22ee2bb417591654a7d2433e196607", size = 7988 },
62
+ ]
63
+
52
64
  [[package]]
53
65
  name = "pandas"
54
66
  version = "2.2.3"
@@ -106,12 +118,13 @@ wheels = [
106
118
 
107
119
  [[package]]
108
120
  name = "relib"
109
- version = "1.3.2"
121
+ version = "1.3.4"
110
122
  source = { editable = "." }
111
123
 
112
124
  [package.dev-dependencies]
113
125
  dev = [
114
126
  { name = "numpy" },
127
+ { name = "omg" },
115
128
  { name = "pandas" },
116
129
  { name = "tqdm" },
117
130
  ]
@@ -121,6 +134,7 @@ dev = [
121
134
  [package.metadata.requires-dev]
122
135
  dev = [
123
136
  { name = "numpy", specifier = ">=2.1.3" },
137
+ { name = "omg", specifier = ">=1.3.6" },
124
138
  { name = "pandas", specifier = ">=2.2.3" },
125
139
  { name = "tqdm", specifier = ">=4.67.1" },
126
140
  ]
@@ -154,3 +168,27 @@ sdist = { url = "https://files.pythonhosted.org/packages/e1/34/943888654477a574a
154
168
  wheels = [
155
169
  { url = "https://files.pythonhosted.org/packages/a6/ab/7e5f53c3b9d14972843a647d8d7a853969a58aecc7559cb3267302c94774/tzdata-2024.2-py2.py3-none-any.whl", hash = "sha256:a48093786cdcde33cad18c2555e8532f34422074448fbc874186f0abd79565cd", size = 346586 },
156
170
  ]
171
+
172
+ [[package]]
173
+ name = "watchdog"
174
+ version = "6.0.0"
175
+ source = { registry = "https://pypi.org/simple" }
176
+ sdist = { url = "https://files.pythonhosted.org/packages/db/7d/7f3d619e951c88ed75c6037b246ddcf2d322812ee8ea189be89511721d54/watchdog-6.0.0.tar.gz", hash = "sha256:9ddf7c82fda3ae8e24decda1338ede66e1c99883db93711d8fb941eaa2d8c282", size = 131220 }
177
+ wheels = [
178
+ { url = "https://files.pythonhosted.org/packages/39/ea/3930d07dafc9e286ed356a679aa02d777c06e9bfd1164fa7c19c288a5483/watchdog-6.0.0-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:bdd4e6f14b8b18c334febb9c4425a878a2ac20efd1e0b231978e7b150f92a948", size = 96471 },
179
+ { url = "https://files.pythonhosted.org/packages/12/87/48361531f70b1f87928b045df868a9fd4e253d9ae087fa4cf3f7113be363/watchdog-6.0.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:c7c15dda13c4eb00d6fb6fc508b3c0ed88b9d5d374056b239c4ad1611125c860", size = 88449 },
180
+ { url = "https://files.pythonhosted.org/packages/5b/7e/8f322f5e600812e6f9a31b75d242631068ca8f4ef0582dd3ae6e72daecc8/watchdog-6.0.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:6f10cb2d5902447c7d0da897e2c6768bca89174d0c6e1e30abec5421af97a5b0", size = 89054 },
181
+ { url = "https://files.pythonhosted.org/packages/68/98/b0345cabdce2041a01293ba483333582891a3bd5769b08eceb0d406056ef/watchdog-6.0.0-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:490ab2ef84f11129844c23fb14ecf30ef3d8a6abafd3754a6f75ca1e6654136c", size = 96480 },
182
+ { url = "https://files.pythonhosted.org/packages/85/83/cdf13902c626b28eedef7ec4f10745c52aad8a8fe7eb04ed7b1f111ca20e/watchdog-6.0.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:76aae96b00ae814b181bb25b1b98076d5fc84e8a53cd8885a318b42b6d3a5134", size = 88451 },
183
+ { url = "https://files.pythonhosted.org/packages/fe/c4/225c87bae08c8b9ec99030cd48ae9c4eca050a59bf5c2255853e18c87b50/watchdog-6.0.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:a175f755fc2279e0b7312c0035d52e27211a5bc39719dd529625b1930917345b", size = 89057 },
184
+ { url = "https://files.pythonhosted.org/packages/a9/c7/ca4bf3e518cb57a686b2feb4f55a1892fd9a3dd13f470fca14e00f80ea36/watchdog-6.0.0-py3-none-manylinux2014_aarch64.whl", hash = "sha256:7607498efa04a3542ae3e05e64da8202e58159aa1fa4acddf7678d34a35d4f13", size = 79079 },
185
+ { url = "https://files.pythonhosted.org/packages/5c/51/d46dc9332f9a647593c947b4b88e2381c8dfc0942d15b8edc0310fa4abb1/watchdog-6.0.0-py3-none-manylinux2014_armv7l.whl", hash = "sha256:9041567ee8953024c83343288ccc458fd0a2d811d6a0fd68c4c22609e3490379", size = 79078 },
186
+ { url = "https://files.pythonhosted.org/packages/d4/57/04edbf5e169cd318d5f07b4766fee38e825d64b6913ca157ca32d1a42267/watchdog-6.0.0-py3-none-manylinux2014_i686.whl", hash = "sha256:82dc3e3143c7e38ec49d61af98d6558288c415eac98486a5c581726e0737c00e", size = 79076 },
187
+ { url = "https://files.pythonhosted.org/packages/ab/cc/da8422b300e13cb187d2203f20b9253e91058aaf7db65b74142013478e66/watchdog-6.0.0-py3-none-manylinux2014_ppc64.whl", hash = "sha256:212ac9b8bf1161dc91bd09c048048a95ca3a4c4f5e5d4a7d1b1a7d5752a7f96f", size = 79077 },
188
+ { url = "https://files.pythonhosted.org/packages/2c/3b/b8964e04ae1a025c44ba8e4291f86e97fac443bca31de8bd98d3263d2fcf/watchdog-6.0.0-py3-none-manylinux2014_ppc64le.whl", hash = "sha256:e3df4cbb9a450c6d49318f6d14f4bbc80d763fa587ba46ec86f99f9e6876bb26", size = 79078 },
189
+ { url = "https://files.pythonhosted.org/packages/62/ae/a696eb424bedff7407801c257d4b1afda455fe40821a2be430e173660e81/watchdog-6.0.0-py3-none-manylinux2014_s390x.whl", hash = "sha256:2cce7cfc2008eb51feb6aab51251fd79b85d9894e98ba847408f662b3395ca3c", size = 79077 },
190
+ { url = "https://files.pythonhosted.org/packages/b5/e8/dbf020b4d98251a9860752a094d09a65e1b436ad181faf929983f697048f/watchdog-6.0.0-py3-none-manylinux2014_x86_64.whl", hash = "sha256:20ffe5b202af80ab4266dcd3e91aae72bf2da48c0d33bdb15c66658e685e94e2", size = 79078 },
191
+ { url = "https://files.pythonhosted.org/packages/07/f6/d0e5b343768e8bcb4cda79f0f2f55051bf26177ecd5651f84c07567461cf/watchdog-6.0.0-py3-none-win32.whl", hash = "sha256:07df1fdd701c5d4c8e55ef6cf55b8f0120fe1aef7ef39a1c6fc6bc2e606d517a", size = 79065 },
192
+ { url = "https://files.pythonhosted.org/packages/db/d9/c495884c6e548fce18a8f40568ff120bc3a4b7b99813081c8ac0c936fa64/watchdog-6.0.0-py3-none-win_amd64.whl", hash = "sha256:cbafb470cf848d93b5d013e2ecb245d4aa1c8fd0504e863ccefa32445359d680", size = 79070 },
193
+ { url = "https://files.pythonhosted.org/packages/33/e8/e40370e6d74ddba47f002a32919d91310d6074130fe4e17dabcafc15cbf1/watchdog-6.0.0-py3-none-win_ia64.whl", hash = "sha256:a1914259fa9e1454315171103c6a30961236f508b9b623eae470268bbcc6a22f", size = 79067 },
194
+ ]
@@ -1,21 +0,0 @@
1
- import json
2
- from pathlib import Path
3
- from typing import Any
4
-
5
- __all__ = [
6
- "read_json",
7
- "write_json",
8
- ]
9
-
10
- default_sentinel = object()
11
-
12
- def read_json(path: Path, default=default_sentinel) -> Any:
13
- if default is not default_sentinel and not path.exists():
14
- return default
15
- with path.open("r") as f:
16
- return json.load(f)
17
-
18
- def write_json(path: Path, obj: object, indent: None | int = None) -> None:
19
- with path.open("w") as f:
20
- separators = (",", ":") if indent is None else None
21
- return json.dump(obj, f, indent=indent, separators=separators)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes