scruby 0.30.2__py3-none-any.whl → 0.31.0__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.

Potentially problematic release.


This version of scruby might be problematic. Click here for more details.

scruby/__init__.py CHANGED
@@ -1,4 +1,3 @@
1
- #
2
1
  # .dP"Y8  dP""b8 88""Yb 88   88 88""Yb Yb  dP
3
2
  # `Ybo." dP   `" 88__dP 88   88 88__dP  YbdP
4
3
  # o.`Y8b Yb      88"Yb  Y8   8P 88""Yb   8P
@@ -6,7 +5,6 @@
6
5
  #
7
6
  # Copyright (c) 2025 Gennady Kostyunin
8
7
  # SPDX-License-Identifier: MIT
9
- #
10
8
  """Asynchronous library for building and managing a hybrid database, by scheme of key-value.
11
9
 
12
10
  The library uses fractal-tree addressing and
scruby/aggregation.py CHANGED
@@ -1,7 +1,6 @@
1
1
  # Scruby - Asynchronous library for building and managing a hybrid database, by scheme of key-value.
2
2
  # Copyright (c) 2025 Gennady Kostyunin
3
3
  # SPDX-License-Identifier: MIT
4
- #
5
4
  """Aggregation classes."""
6
5
 
7
6
  from __future__ import annotations
scruby/db.py CHANGED
@@ -1,7 +1,6 @@
1
1
  # Scruby - Asynchronous library for building and managing a hybrid database, by scheme of key-value.
2
2
  # Copyright (c) 2025 Gennady Kostyunin
3
3
  # SPDX-License-Identifier: MIT
4
- #
5
4
  """Creation and management of the database."""
6
5
 
7
6
  from __future__ import annotations
scruby/errors.py CHANGED
@@ -1,7 +1,6 @@
1
1
  # Scruby - Asynchronous library for building and managing a hybrid database, by scheme of key-value.
2
2
  # Copyright (c) 2025 Gennady Kostyunin
3
3
  # SPDX-License-Identifier: MIT
4
- #
5
4
  """Scruby Exceptions."""
6
5
 
7
6
  from __future__ import annotations
scruby/mixins/__init__.py CHANGED
@@ -1,7 +1,6 @@
1
1
  # Scruby - Asynchronous library for building and managing a hybrid database, by scheme of key-value.
2
2
  # Copyright (c) 2025 Gennady Kostyunin
3
3
  # SPDX-License-Identifier: MIT
4
- #
5
4
  """Mixins."""
6
5
 
7
6
  from __future__ import annotations
@@ -1,7 +1,6 @@
1
1
  # Scruby - Asynchronous library for building and managing a hybrid database, by scheme of key-value.
2
2
  # Copyright (c) 2025 Gennady Kostyunin
3
3
  # SPDX-License-Identifier: MIT
4
- #
5
4
  """Methods for working with collections."""
6
5
 
7
6
  from __future__ import annotations
scruby/mixins/count.py CHANGED
@@ -1,7 +1,6 @@
1
1
  # Scruby - Asynchronous library for building and managing a hybrid database, by scheme of key-value.
2
2
  # Copyright (c) 2025 Gennady Kostyunin
3
3
  # SPDX-License-Identifier: MIT
4
- #
5
4
  """Methods for counting the number of documents."""
6
5
 
7
6
  from __future__ import annotations
@@ -1,7 +1,6 @@
1
1
  # Scruby - Asynchronous library for building and managing a hybrid database, by scheme of key-value.
2
2
  # Copyright (c) 2025 Gennady Kostyunin
3
3
  # SPDX-License-Identifier: MIT
4
- #
5
4
  """Quantum methods for running custom tasks."""
6
5
 
7
6
  from __future__ import annotations
@@ -11,46 +10,16 @@ __all__ = ("CustomTask",)
11
10
  from collections.abc import Callable
12
11
  from typing import Any
13
12
 
14
- import orjson
15
- from anyio import Path
16
-
17
13
 
18
14
  class CustomTask:
19
15
  """Quantum methods for running custom tasks."""
20
16
 
21
- @staticmethod
22
- async def _task_get_docs(
23
- branch_number: int,
24
- hash_reduce_left: int,
25
- db_root: str,
26
- class_model: Any,
27
- ) -> list[Any]:
28
- """Get documents for custom task.
29
-
30
- This method is for internal use.
31
-
32
- Returns:
33
- List of documents.
34
- """
35
- branch_number_as_hash: str = f"{branch_number:08x}"[hash_reduce_left:]
36
- separated_hash: str = "/".join(list(branch_number_as_hash))
37
- leaf_path: Path = Path(
38
- *(
39
- db_root,
40
- class_model.__name__,
41
- separated_hash,
42
- "leaf.json",
43
- ),
44
- )
45
- docs: list[Any] = []
46
- if await leaf_path.exists():
47
- data_json: bytes = await leaf_path.read_bytes()
48
- data: dict[str, str] = orjson.loads(data_json) or {}
49
- for _, val in data.items():
50
- docs.append(class_model.model_validate_json(val))
51
- return docs
52
-
53
- async def run_custom_task(self, custom_task_fn: Callable) -> Any:
17
+ async def run_custom_task(
18
+ self,
19
+ custom_task_fn: Callable,
20
+ filter_fn: Callable = lambda _: True,
21
+ **kwargs,
22
+ ) -> Any:
54
23
  """Running custom task.
55
24
 
56
25
  Attention:
@@ -63,12 +32,13 @@ class CustomTask:
63
32
  Returns:
64
33
  The result of a custom task.
65
34
  """
66
- kwargs = {
67
- "get_docs_fn": self._task_get_docs,
68
- "branch_numbers": range(self._max_number_branch),
69
- "hash_reduce_left": self._hash_reduce_left,
70
- "db_root": self._db_root,
71
- "class_model": self._class_model,
72
- "max_workers": self._max_workers,
73
- }
74
- return await custom_task_fn(**kwargs)
35
+ return await custom_task_fn(
36
+ search_task_fn=self._task_find,
37
+ filter_fn=filter_fn,
38
+ branch_numbers=range(self._max_number_branch),
39
+ hash_reduce_left=self._hash_reduce_left,
40
+ db_root=self._db_root,
41
+ class_model=self._class_model,
42
+ max_workers=self._max_workers,
43
+ **kwargs,
44
+ )
scruby/mixins/delete.py CHANGED
@@ -1,7 +1,6 @@
1
1
  # Scruby - Asynchronous library for building and managing a hybrid database, by scheme of key-value.
2
2
  # Copyright (c) 2025 Gennady Kostyunin
3
3
  # SPDX-License-Identifier: MIT
4
- #
5
4
  """Methods for deleting documents."""
6
5
 
7
6
  from __future__ import annotations
scruby/mixins/find.py CHANGED
@@ -1,7 +1,6 @@
1
1
  # Scruby - Asynchronous library for building and managing a hybrid database, by scheme of key-value.
2
2
  # Copyright (c) 2025 Gennady Kostyunin
3
3
  # SPDX-License-Identifier: MIT
4
- #
5
4
  """Quantum methods for searching documents."""
6
5
 
7
6
  from __future__ import annotations
@@ -34,7 +33,6 @@ class Find:
34
33
  Returns:
35
34
  List of documents or None.
36
35
  """
37
- # Variable initialization
38
36
  branch_number_as_hash: str = f"{branch_number:08x}"[hash_reduce_left:]
39
37
  separated_hash: str = "/".join(list(branch_number_as_hash))
40
38
  leaf_path: Path = Path(
@@ -109,7 +107,7 @@ class Find:
109
107
  filter_fn (Callable): A function that execute the conditions of filtering.
110
108
  By default it searches for all documents.
111
109
  limit_docs (int): Limiting the number of documents. By default = 1000.
112
- page_number (int): For pagination output. By default = 1.
110
+ page_number (int): For pagination. By default = 1.
113
111
  Number of documents per page = limit_docs.
114
112
 
115
113
  Returns:
scruby/mixins/keys.py CHANGED
@@ -1,7 +1,6 @@
1
1
  # Scruby - Asynchronous library for building and managing a hybrid database, by scheme of key-value.
2
2
  # Copyright (c) 2025 Gennady Kostyunin
3
3
  # SPDX-License-Identifier: MIT
4
- #
5
4
  """Methods for working with keys."""
6
5
 
7
6
  from __future__ import annotations
scruby/mixins/update.py CHANGED
@@ -1,7 +1,6 @@
1
1
  # Scruby - Asynchronous library for building and managing a hybrid database, by scheme of key-value.
2
2
  # Copyright (c) 2025 Gennady Kostyunin
3
3
  # SPDX-License-Identifier: MIT
4
- #
5
4
  """Methods for updating documents."""
6
5
 
7
6
  from __future__ import annotations
scruby/settings.py CHANGED
@@ -1,7 +1,6 @@
1
1
  # Scruby - Asynchronous library for building and managing a hybrid database, by scheme of key-value.
2
2
  # Copyright (c) 2025 Gennady Kostyunin
3
3
  # SPDX-License-Identifier: MIT
4
- #
5
4
  """Database settings.
6
5
 
7
6
  The module contains the following parameters:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scruby
3
- Version: 0.30.2
3
+ Version: 0.31.0
4
4
  Summary: Asynchronous library for building and managing a hybrid database, by scheme of key-value.
5
5
  Project-URL: Homepage, https://kebasyaty.github.io/scruby/
6
6
  Project-URL: Repository, https://github.com/kebasyaty/scruby
@@ -150,7 +150,7 @@ async def main() -> None:
150
150
  user = User(
151
151
  first_name="John",
152
152
  last_name="Smith",
153
- birthday=datetime.datetime(1970, 1, 1, tzinfo=ZoneInfo("UTC")),
153
+ birthday=datetime(1970, 1, 1, tzinfo=ZoneInfo("UTC")),
154
154
  email="John_Smith@gmail.com",
155
155
  phone="+447986123456",
156
156
  )
@@ -186,7 +186,6 @@ The search effectiveness depends on the number of processor threads.
186
186
  """
187
187
 
188
188
  import anyio
189
- from datetime import datetime
190
189
  from typing import Annotated
191
190
  from pydantic import Field
192
191
  from scruby import Scruby, ScrubyModel, settings
@@ -262,7 +261,6 @@ The search effectiveness depends on the number of processor threads.
262
261
  """
263
262
 
264
263
  import anyio
265
- from datetime import datetime
266
264
  from typing import Annotated
267
265
  from pydantic import Field
268
266
  from scruby import Scruby, ScrubyModel, settings
@@ -0,0 +1,18 @@
1
+ scruby/__init__.py,sha256=m5VkmOTqVzfHsLb7eIfGTdBpWPwEayrRDpAilUuksGc,1042
2
+ scruby/aggregation.py,sha256=ooDN2KShP_JwIpIqxz7wL6gtBdd4oCSFk_3BhnD2o50,3489
3
+ scruby/db.py,sha256=EVrMfHYWZr9ZEyU7b2fMBqSKeh0fEJnjbihQhMNVJak,8374
4
+ scruby/errors.py,sha256=F51l5eyJuuMrwPeiIy6IGc1GqMsrGuS6l_B0e0Y6xWs,1295
5
+ scruby/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ scruby/settings.py,sha256=g2AYH8QorjoTYxMceWotFL9X3F2mQnKDl9dlgmSLa5c,1578
7
+ scruby/mixins/__init__.py,sha256=9geOyHcfWV4hilYs76whiEUOK2aZtgeC0fg2K0qvUOk,625
8
+ scruby/mixins/collection.py,sha256=SZ2yvPPPPu_Cg9pfqu_RM0YB6hkhikwmuE13sATeUtE,1380
9
+ scruby/mixins/count.py,sha256=gYX7ttHjHINZjSWa6FjzMZnqwEQO9kj5Ehl7Hkcs-2E,2087
10
+ scruby/mixins/custom_task.py,sha256=tHZSo6IdZL5Yu46S-c7Ac3ImxGhwzPoQm4Dp4O8bqLs,1320
11
+ scruby/mixins/delete.py,sha256=ng0xXM9mKQy5iq04WCyDm2AseETzEV7PgQOeDzUe-uU,3083
12
+ scruby/mixins/find.py,sha256=5X0PNvLtsPq8s9J-lNFrhT9Pmqn4qSYUmSsV9yCl3VE,5353
13
+ scruby/mixins/keys.py,sha256=ybCHefGgxXNCYMKxgRhlXXW1CLcv2BGKff3S8E1y2JI,6177
14
+ scruby/mixins/update.py,sha256=PWrF1lvuMOHIlsrfXMB6jfCFEGbpqXor-CzH5X0b3VE,3414
15
+ scruby-0.31.0.dist-info/METADATA,sha256=f1Ad9XPgW1euUdbxe0SbxpKQ0qjiybSMADCu_e4QxPw,10963
16
+ scruby-0.31.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
17
+ scruby-0.31.0.dist-info/licenses/LICENSE,sha256=mS0Wz0yGNB63gEcWEnuIb_lldDYV0sjRaO-o_GL6CWE,1074
18
+ scruby-0.31.0.dist-info/RECORD,,
@@ -1,18 +0,0 @@
1
- scruby/__init__.py,sha256=WuIA27d3uUK0Vo0fXg92hge7i6v_2DBndhfepK16_y8,1046
2
- scruby/aggregation.py,sha256=bd70J1Xye6faNHD8LS3lVQoHWKtPdPV_cqT_i7oui38,3491
3
- scruby/db.py,sha256=4bSPMh0fYil0j9qhHhRu1g4U_0WaCuaGPthnmi2QpBI,8376
4
- scruby/errors.py,sha256=D0jisudUsZk9iXp4nRSymaSMwyqHPVshsSlxx4HDVVk,1297
5
- scruby/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
- scruby/settings.py,sha256=_uVdZIGWoi6q9zcu0c2PS51OBEBNASRRrxfzaF7Nwy0,1580
7
- scruby/mixins/__init__.py,sha256=XPMjJvOZN7dLpTE1FfGMBGQ_0421HXug-0rWKMU5fRQ,627
8
- scruby/mixins/collection.py,sha256=coF-IOhicV_EihDwnYf6SW5Mfi3nOFR0gAhCc619NmI,1382
9
- scruby/mixins/count.py,sha256=YHjonxAtroSc5AlbDX1vpCvbe3vsTD0LfYnjEDB001A,2089
10
- scruby/mixins/custom_task.py,sha256=ENr3FkCsPWRblOWv8jGMkkGKw4hvp9mMP2YjQvIeqzE,2246
11
- scruby/mixins/delete.py,sha256=b7RYiTLUqVu70ep15CN1VTyKs13P7f-1YDGRc3ke-2g,3085
12
- scruby/mixins/find.py,sha256=-rpILkxhfywJ5E3ceYo9dSPabma47ouceGajUVNh23Q,5396
13
- scruby/mixins/keys.py,sha256=waxye5n0-oTWIhdDXGQkUTGaV9vLSCc9lCryTCuexkw,6179
14
- scruby/mixins/update.py,sha256=WeNk2qZToQS3-r1_ahazBc2ErLMU9K5RRNgCxbu3JMg,3416
15
- scruby-0.30.2.dist-info/METADATA,sha256=OgV4Foj3-X97NKFLpw_8Qb_osGwmYIINO2UZkgdLaY0,11032
16
- scruby-0.30.2.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
17
- scruby-0.30.2.dist-info/licenses/LICENSE,sha256=mS0Wz0yGNB63gEcWEnuIb_lldDYV0sjRaO-o_GL6CWE,1074
18
- scruby-0.30.2.dist-info/RECORD,,