scruby 0.10.3__py3-none-any.whl → 0.10.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.

Potentially problematic release.


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

scruby/constants.py CHANGED
@@ -3,7 +3,7 @@
3
3
  The module contains the following variables:
4
4
 
5
5
  - `DB_ROOT` - Path to root directory of database. `By default = "ScrubyDB"` (*in root of project*).
6
- - `LENGTH_REDUCTION_HASH` - The length of the hash reduction on the left side.
6
+ - `HASH_REDUCE_LEFT` - The length of the hash reduction on the left side.
7
7
  - `0` - 4294967296 branches in collection (by default).
8
8
  - `2` - 16777216 branches in collectionю
9
9
  - `4` - 65536 branches in collectionю
@@ -14,7 +14,7 @@ from __future__ import annotations
14
14
 
15
15
  __all__ = (
16
16
  "DB_ROOT",
17
- "LENGTH_REDUCTION_HASH",
17
+ "HASH_REDUCE_LEFT",
18
18
  )
19
19
 
20
20
  from typing import Literal
@@ -28,4 +28,4 @@ DB_ROOT: str = "ScrubyDB"
28
28
  # 2 = 16777216 branches in collectionю
29
29
  # 4 = 65536 branches in collectionю
30
30
  # 6 = 256 branches in collection (main purpose is tests).
31
- LENGTH_REDUCTION_HASH: Literal[0, 2, 4, 6] = 0
31
+ HASH_REDUCE_LEFT: Literal[0, 2, 4, 6] = 0
scruby/db.py CHANGED
@@ -27,9 +27,6 @@ T = TypeVar("T")
27
27
  class _Meta(BaseModel):
28
28
  """Metadata of Collection."""
29
29
 
30
- db_root: str
31
- model_name: str
32
- length_reduction_hash: int
33
30
  counter_documents: int
34
31
 
35
32
 
@@ -47,9 +44,9 @@ class Scruby[T]:
47
44
  self.__meta = _Meta
48
45
  self.__class_model = class_model
49
46
  self.__db_root = constants.DB_ROOT
50
- self.__length_reduction_hash = constants.LENGTH_REDUCTION_HASH
47
+ self.__hash_reduce_left = constants.HASH_REDUCE_LEFT
51
48
  # The maximum number of keys.
52
- match self.__length_reduction_hash:
49
+ match self.__hash_reduce_left:
53
50
  case 0:
54
51
  self.__max_num_keys = 4294967296
55
52
  case 2:
@@ -59,7 +56,7 @@ class Scruby[T]:
59
56
  case 6:
60
57
  self.__max_num_keys = 256
61
58
  case _ as unreachable:
62
- msg: str = f"{unreachable} - Unacceptable value for LENGTH_REDUCTION_HASH."
59
+ msg: str = f"{unreachable} - Unacceptable value for HASH_REDUCE_LEFT."
63
60
  logger.critical(msg)
64
61
  assert_never(Never(unreachable))
65
62
  # 1.Create metadata if absent.
@@ -72,7 +69,7 @@ class Scruby[T]:
72
69
  This method is for internal use.
73
70
  """
74
71
  key: int = 0
75
- key_as_hash: str = f"{key:08x}"[self.__length_reduction_hash :]
72
+ key_as_hash: str = f"{key:08x}"[self.__hash_reduce_left :]
76
73
  separated_hash: str = "/".join(list(key_as_hash))
77
74
  branch_path = SyncPath(
78
75
  *(
@@ -84,9 +81,6 @@ class Scruby[T]:
84
81
  if not branch_path.exists():
85
82
  branch_path.mkdir(parents=True)
86
83
  meta = _Meta(
87
- db_root=self.__db_root,
88
- model_name=self.__class_model.__name__,
89
- length_reduction_hash=self.__length_reduction_hash,
90
84
  counter_documents=0,
91
85
  )
92
86
  meta_json = meta.model_dump_json()
@@ -99,7 +93,7 @@ class Scruby[T]:
99
93
  This method is for internal use.
100
94
  """
101
95
  key: int = 0
102
- key_as_hash: str = f"{key:08x}"[self.__length_reduction_hash :]
96
+ key_as_hash: str = f"{key:08x}"[self.__hash_reduce_left :]
103
97
  separated_hash: str = "/".join(list(key_as_hash))
104
98
  return Path(
105
99
  *(
@@ -155,7 +149,7 @@ class Scruby[T]:
155
149
  logger.error("The key should not be empty.")
156
150
  raise KeyError("The key should not be empty.")
157
151
  # Key to crc32 sum.
158
- key_as_hash: str = f"{zlib.crc32(key.encode('utf-8')):08x}"[self.__length_reduction_hash :]
152
+ key_as_hash: str = f"{zlib.crc32(key.encode('utf-8')):08x}"[self.__hash_reduce_left :]
159
153
  # Convert crc32 sum in the segment of path.
160
154
  separated_hash: str = "/".join(list(key_as_hash))
161
155
  # The path of the branch to the database.
@@ -275,7 +269,7 @@ class Scruby[T]:
275
269
  def _task_find(
276
270
  key: int,
277
271
  filter_fn: Callable,
278
- length_reduction_hash: str,
272
+ HASH_REDUCE_LEFT: str,
279
273
  db_root: str,
280
274
  class_model: T,
281
275
  ) -> dict[str, Any] | None:
@@ -283,7 +277,7 @@ class Scruby[T]:
283
277
 
284
278
  This method is for internal use.
285
279
  """
286
- key_as_hash: str = f"{key:08x}"[length_reduction_hash:]
280
+ key_as_hash: str = f"{key:08x}"[HASH_REDUCE_LEFT:]
287
281
  separated_hash: str = "/".join(list(key_as_hash))
288
282
  leaf_path: SyncPath = SyncPath(
289
283
  *(
@@ -324,7 +318,7 @@ class Scruby[T]:
324
318
  """
325
319
  keys: range = range(1, self.__max_num_keys)
326
320
  search_task_fn: Callable = self._task_find
327
- length_reduction_hash: int = self.__length_reduction_hash
321
+ HASH_REDUCE_LEFT: int = self.__hash_reduce_left
328
322
  db_root: str = self.__db_root
329
323
  class_model: T = self.__class_model
330
324
  with concurrent.futures.ThreadPoolExecutor(max_workers) as executor:
@@ -333,7 +327,7 @@ class Scruby[T]:
333
327
  search_task_fn,
334
328
  key,
335
329
  filter_fn,
336
- length_reduction_hash,
330
+ HASH_REDUCE_LEFT,
337
331
  db_root,
338
332
  class_model,
339
333
  )
@@ -366,7 +360,7 @@ class Scruby[T]:
366
360
  """
367
361
  keys: range = range(1, self.__max_num_keys)
368
362
  search_task_fn: Callable = self._task_find
369
- length_reduction_hash: int = self.__length_reduction_hash
363
+ HASH_REDUCE_LEFT: int = self.__hash_reduce_left
370
364
  db_root: str = self.__db_root
371
365
  class_model: T = self.__class_model
372
366
  counter: int = 0
@@ -379,7 +373,7 @@ class Scruby[T]:
379
373
  search_task_fn,
380
374
  key,
381
375
  filter_fn,
382
- length_reduction_hash,
376
+ HASH_REDUCE_LEFT,
383
377
  db_root,
384
378
  class_model,
385
379
  )
@@ -424,7 +418,7 @@ class Scruby[T]:
424
418
  """
425
419
  keys: range = range(1, self.__max_num_keys)
426
420
  search_task_fn: Callable = self._task_find
427
- length_reduction_hash: int = self.__length_reduction_hash
421
+ HASH_REDUCE_LEFT: int = self.__hash_reduce_left
428
422
  db_root: str = self.__db_root
429
423
  class_model: T = self.__class_model
430
424
  counter: int = 0
@@ -434,7 +428,7 @@ class Scruby[T]:
434
428
  search_task_fn,
435
429
  key,
436
430
  filter_fn,
437
- length_reduction_hash,
431
+ HASH_REDUCE_LEFT,
438
432
  db_root,
439
433
  class_model,
440
434
  )
scruby/errors.py CHANGED
@@ -1,14 +1,17 @@
1
- """XLOT Exceptions."""
1
+ """Scruby Exceptions."""
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
- __all__ = ("MetadataValueError",)
5
+ __all__ = (
6
+ "ScrubyException",
7
+ "MetadataValueError",
8
+ )
6
9
 
7
10
 
8
11
  class ScrubyException(Exception):
9
12
  """Root Custom Exception."""
10
13
 
11
- def __init__(self, *args, **kwargs) -> None: # type: ignore[no-untyped-def]
14
+ def __init__(self, *args, **kwargs) -> None: # type: ignore[no-untyped-def] # noqa: D107
12
15
  super().__init__(*args, **kwargs)
13
16
 
14
17
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scruby
3
- Version: 0.10.3
3
+ Version: 0.10.4
4
4
  Summary: A fast key-value storage library.
5
5
  Project-URL: Homepage, https://github.com/kebasyaty/scruby
6
6
  Project-URL: Repository, https://github.com/kebasyaty/scruby
@@ -175,7 +175,7 @@ from scruby import Scruby, constants
175
175
  from pprint import pprint as pp
176
176
 
177
177
  constants.DB_ROOT = "ScrubyDB" # By default = "ScrubyDB"
178
- constants.LENGTH_REDUCTION_HASH = 6 # 256 branches in collection
178
+ constants.HASH_REDUCE_LEFT = 6 # 256 branches in collection
179
179
  # (main purpose is tests).
180
180
 
181
181
  class User(BaseModel):
@@ -246,7 +246,7 @@ from scruby import Scruby, constants
246
246
  from pprint import pprint as pp
247
247
 
248
248
  constants.DB_ROOT = "ScrubyDB" # By default = "ScrubyDB"
249
- constants.LENGTH_REDUCTION_HASH = 6 # 256 branches in collection
249
+ constants.HASH_REDUCE_LEFT = 6 # 256 branches in collection
250
250
  # (main purpose is tests).
251
251
 
252
252
  class User(BaseModel):
@@ -0,0 +1,9 @@
1
+ scruby/__init__.py,sha256=wFwUS1KcLxfIopXOVS8gPue9fNzIIU2cVj_RgK5drz4,849
2
+ scruby/constants.py,sha256=3LZfcxcuRqwzoB0-iogLMjKBZRdxfWJmTbyPwVRhQgY,1007
3
+ scruby/db.py,sha256=k_I2rphHG7Y5vq8oGDoimlKEwPEwmYzkqn7_DO0M6ic,15853
4
+ scruby/errors.py,sha256=aHQri4LNcFVQrSHwjyzb1fL8O49SwjYEU4QgMOo4uyA,622
5
+ scruby/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ scruby-0.10.4.dist-info/METADATA,sha256=oJLzRBPPatu6dsq7EQyxf-UHQn4uJ1kF3C7Q-heqVNw,10819
7
+ scruby-0.10.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
8
+ scruby-0.10.4.dist-info/licenses/LICENSE,sha256=2zZINd6m_jNYlowdQImlEizyhSui5cBAJZRhWQURcEc,1095
9
+ scruby-0.10.4.dist-info/RECORD,,
@@ -1,9 +0,0 @@
1
- scruby/__init__.py,sha256=wFwUS1KcLxfIopXOVS8gPue9fNzIIU2cVj_RgK5drz4,849
2
- scruby/constants.py,sha256=GbB-O0qaVdi5EHUp-zRAppFXLR-oHxpXUFVAOCpS0C8,1022
3
- scruby/db.py,sha256=J14Xjyc6iyb-cwBKiH8rJuioEHoYfNkLTezzvQBsJng,16181
4
- scruby/errors.py,sha256=4G0zNVzulBE9mM2iJLdg0EXP_W8n-L6EjZrkCCErvAU,574
5
- scruby/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
- scruby-0.10.3.dist-info/METADATA,sha256=JGgVH8QKtA-iGifWhNdSczfuglIT2RRw5njRuNKvG3M,10829
7
- scruby-0.10.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
8
- scruby-0.10.3.dist-info/licenses/LICENSE,sha256=2zZINd6m_jNYlowdQImlEizyhSui5cBAJZRhWQURcEc,1095
9
- scruby-0.10.3.dist-info/RECORD,,