scruby 2.2.0__py3-none-any.whl → 2.2.1__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.
scruby/config.py CHANGED
@@ -6,8 +6,8 @@
6
6
 
7
7
  The settings class contains the following parameters:
8
8
 
9
- - `db_root` - Path to root directory of database. `Default = "ScrubyDB" (in root of project)`.
10
9
  - `db_id` - Database ID.
10
+ - `db_root` - Path to root directory of database. `Default = "ScrubyDB" (in root of project)`.
11
11
  - `HASH_REDUCE_LEFT` - The length of the hash reduction on the left side.
12
12
  - `7` - 16 branches in collection (is default).
13
13
  - `6` - 256 branches in collection.
@@ -34,14 +34,14 @@ from scruby.utils import add_to_env, get_from_env
34
34
  class ScrubyConfig:
35
35
  """Database settings."""
36
36
 
37
- # Path to root directory of database
38
- # By default = "ScrubyDB" (in root of project).
39
- db_root: ClassVar[str] = "ScrubyDB"
40
-
41
37
  # Database ID
42
38
  # Will be automatically assigned.
43
39
  db_id: ClassVar[str | None] = None
44
40
 
41
+ # Path to root directory of database
42
+ # By default = "ScrubyDB" (in root of project).
43
+ db_root: ClassVar[str] = "ScrubyDB"
44
+
45
45
  # The length of the hash reduction on the left side.
46
46
  # 7 = 16 branches in collection.
47
47
  # 6 = 256 branches in collection (is default).
@@ -134,3 +134,14 @@ class ScrubyConfig:
134
134
  + f"is not equal to the primary value {hash_reduce_left}."
135
135
  )
136
136
  raise ValueError(msg)
137
+
138
+ @classmethod
139
+ def restore(cls) -> None:
140
+ """Restore default parameter values."""
141
+ cls.db_id = None
142
+ cls.db_root = "ScrubyDB"
143
+ cls.HASH_REDUCE_LEFT = 7
144
+ cls.MAX_NUMBER_BRANCH = 16
145
+ cls.max_workers = None
146
+ cls.plugins = None
147
+ cls.sys_platform = sys.platform
scruby/db.py CHANGED
@@ -60,8 +60,8 @@ class Scruby(
60
60
  ) -> None:
61
61
  super().__init__()
62
62
  self._meta = _Meta
63
- self._db_root = ScrubyConfig.db_root
64
63
  self._db_id = ScrubyConfig.db_id
64
+ self._db_root = ScrubyConfig.db_root
65
65
  self._hash_reduce_left = ScrubyConfig.HASH_REDUCE_LEFT
66
66
  self._max_number_branch = ScrubyConfig.MAX_NUMBER_BRANCH
67
67
  self._max_workers = ScrubyConfig.max_workers
@@ -126,8 +126,8 @@ class Scruby(
126
126
  await meta_dir_path.mkdir(parents=True)
127
127
  meta = _Meta(
128
128
  collection_name=class_model.__name__,
129
- hash_reduce_left=ScrubyConfig.HASH_REDUCE_LEFT,
130
- max_number_branch=ScrubyConfig.MAX_NUMBER_BRANCH,
129
+ hash_reduce_left=instance.__dict__["_hash_reduce_left"],
130
+ max_number_branch=instance.__dict__["_max_number_branch"],
131
131
  counter_documents=0,
132
132
  )
133
133
  # Save metadata of collection.
@@ -245,6 +245,7 @@ class Scruby(
245
245
  DocCache.cache = {}
246
246
  with contextlib.suppress(FileNotFoundError):
247
247
  rmtree(ScrubyConfig.db_root)
248
+ ScrubyConfig.restore()
248
249
  return
249
250
 
250
251
  @staticmethod
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scruby
3
- Version: 2.2.0
3
+ Version: 2.2.1
4
4
  Summary: Asynchronous library for building and managing a hybrid database, by scheme of key-value.
5
5
  Project-URL: Bug Tracker, https://github.com/kebasyaty/scruby/issues
6
6
  Project-URL: Changelog, https://github.com/kebasyaty/scruby/blob/v2/CHANGELOG.md
@@ -1,8 +1,8 @@
1
1
  scruby/__init__.py,sha256=DEtbZThadMKpKcGGjWyAFGu4IADg9ZYTb8WjfO_3Dqg,1300
2
2
  scruby/aggregation.py,sha256=NBFxQqyRqUG2KIuD9fbl4uzSHJWTaskjiZ1YNBa-Zbo,3575
3
3
  scruby/cache.py,sha256=hRj9Ix4XeYQzoAtav5lSXxuBZaxpqMzTg0sYAMBIEjM,3768
4
- scruby/config.py,sha256=Wf_mY-GpKhUvGmN7LBFMvRJ3bsYI0nVH6BjH9LWxosg,4802
5
- scruby/db.py,sha256=QRfC8BTMhlOlqTI2fYRtPsUjmtQUGyQX6eXATA9xHL4,9950
4
+ scruby/config.py,sha256=INAFqNAeF8BifIywjElC97rawfTLuqpRfieUdAO7A6k,5122
5
+ scruby/db.py,sha256=OtAwHtXoHaF_obqMwxn157EtVppO0tO6Dx2lWGFBEiA,9999
6
6
  scruby/errors.py,sha256=lTWiHzyO5Es9Nkf7quODJjONGn6ifcL95qlpA4epQQM,1386
7
7
  scruby/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
8
  scruby/utils.py,sha256=ZwWxSyh_BAOQkXlIqXFOlX2lHVk9rfYGQiVqtTk8PpE,1865
@@ -14,8 +14,8 @@ scruby/mixins/delete.py,sha256=InKVIud_ZYx9-CchUz_IygQDXMynNi4jQ0HKYeHC_R8,4328
14
14
  scruby/mixins/find.py,sha256=oEZRE6RqIBdwvNr8iSYyod8hI6ibi_egJP0pyXmJiss,9169
15
15
  scruby/mixins/keys.py,sha256=MvBy_8fQGROaQATK2qse2V8wR-xodPQG0KKZ2PK_t9U,10790
16
16
  scruby/mixins/update.py,sha256=TyxvxB-gNijlfzTmhwrq0ydvu0C3R-RihW5h5tJ96bM,4964
17
- scruby-2.2.0.dist-info/METADATA,sha256=it-UTILKAB_3J-yJmZTke73CEcaoorDqlaLwQE_rcwc,13500
18
- scruby-2.2.0.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
19
- scruby-2.2.0.dist-info/licenses/GPL-3.0-LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
20
- scruby-2.2.0.dist-info/licenses/MIT-LICENSE,sha256=mS0Wz0yGNB63gEcWEnuIb_lldDYV0sjRaO-o_GL6CWE,1074
21
- scruby-2.2.0.dist-info/RECORD,,
17
+ scruby-2.2.1.dist-info/METADATA,sha256=Rpmh_TEK9wIRrJFR_U_U31H-pYgU0P7dgy2xpLTy9KU,13500
18
+ scruby-2.2.1.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
19
+ scruby-2.2.1.dist-info/licenses/GPL-3.0-LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
20
+ scruby-2.2.1.dist-info/licenses/MIT-LICENSE,sha256=mS0Wz0yGNB63gEcWEnuIb_lldDYV0sjRaO-o_GL6CWE,1074
21
+ scruby-2.2.1.dist-info/RECORD,,
File without changes