persidict 0.32.7__tar.gz → 0.32.8__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.

Potentially problematic release.


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

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: persidict
3
- Version: 0.32.7
3
+ Version: 0.32.8
4
4
  Summary: Simple persistent key-value store for Python. Values are stored as files on a disk or as S3 objects on AWS cloud.
5
5
  Keywords: persistence,dicts,distributed,parallel
6
6
  Author: Vlad (Volodymyr) Pavlov
@@ -4,7 +4,7 @@ build-backend = "uv_build"
4
4
 
5
5
  [project]
6
6
  name = "persidict"
7
- version = "0.32.7"
7
+ version = "0.32.8"
8
8
  description = "Simple persistent key-value store for Python. Values are stored as files on a disk or as S3 objects on AWS cloud."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -139,23 +139,9 @@ class FileDirDict(PersiDict):
139
139
  def __len__(self) -> int:
140
140
  """ Get the number of key-value pairs in the dictionary."""
141
141
 
142
- num_files = 0
143
142
  suffix = "." + self.file_type
144
- stack = [self._base_dir]
145
-
146
- while stack:
147
- path = stack.pop()
148
- try:
149
- with os.scandir(path) as it:
150
- for entry in it:
151
- if entry.is_dir(follow_symlinks=False):
152
- stack.append(entry.path)
153
- elif entry.is_file(follow_symlinks=False) and entry.name.endswith(suffix):
154
- num_files += 1
155
- except PermissionError:
156
- continue
157
-
158
- return num_files
143
+ return sum(1 for _, _, files in os.walk(self._base_dir)
144
+ for f in files if f.endswith(suffix))
159
145
 
160
146
 
161
147
  def clear(self) -> None:
@@ -174,6 +160,7 @@ class FileDirDict(PersiDict):
174
160
  len(os.listdir(subdir_name)) == 0 ):
175
161
  os.rmdir(subdir_name)
176
162
 
163
+
177
164
  def _build_full_path(self
178
165
  , key:SafeStrTuple
179
166
  , create_subdirs:bool=False
@@ -424,7 +411,8 @@ class FileDirDict(PersiDict):
424
411
  to_return.append(key_to_return)
425
412
 
426
413
  if "values" in result_type:
427
- value_to_return = self[result_key]
414
+ full_path = os.path.join(dir_name, f)
415
+ value_to_return = self._read_from_file(full_path)
428
416
  to_return.append(value_to_return)
429
417
 
430
418
  if len(result_type) == 1:
@@ -1,12 +1,11 @@
1
1
  import string
2
- from copy import deepcopy
3
2
 
4
3
  SAFE_CHARS_SET = set(string.ascii_letters + string.digits + "()_-~.=")
5
4
  SAFE_STRING_MAX_LENGTH = 254
6
5
 
7
6
  def get_safe_chars() -> set[str]:
8
7
  """Return a set of allowed characters."""
9
- return deepcopy(SAFE_CHARS_SET)
8
+ return SAFE_CHARS_SET.copy()
10
9
 
11
10
  def replace_unsafe_chars(a_str:str, replace_with:str) -> str :
12
11
  """ Replace unsafe (special) characters with allowed (safe) ones."""
@@ -1,6 +1,7 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import time
4
+ from functools import cache
4
5
 
5
6
  from deepdiff import DeepDiff
6
7
  from parameterizable import register_parameterizable_class, sort_dict_by_keys
File without changes