python-benedict 0.33.1__tar.gz → 0.34.0__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.
Files changed (76) hide show
  1. {python-benedict-0.33.1/python_benedict.egg-info → python_benedict-0.34.0}/PKG-INFO +8 -9
  2. {python-benedict-0.33.1 → python_benedict-0.34.0}/README.md +6 -6
  3. python_benedict-0.34.0/benedict/core/clean.py +55 -0
  4. {python-benedict-0.33.1 → python_benedict-0.34.0}/benedict/dicts/__init__.py +5 -1
  5. {python-benedict-0.33.1 → python_benedict-0.34.0}/benedict/dicts/keylist/keylist_dict.py +6 -6
  6. {python-benedict-0.33.1 → python_benedict-0.34.0}/benedict/dicts/keypath/keypath_util.py +1 -1
  7. {python-benedict-0.33.1 → python_benedict-0.34.0}/benedict/metadata.py +1 -1
  8. {python-benedict-0.33.1 → python_benedict-0.34.0}/pyproject.toml +5 -4
  9. {python-benedict-0.33.1 → python_benedict-0.34.0/python_benedict.egg-info}/PKG-INFO +8 -9
  10. python-benedict-0.33.1/benedict/core/clean.py +0 -19
  11. {python-benedict-0.33.1 → python_benedict-0.34.0}/LICENSE.txt +0 -0
  12. {python-benedict-0.33.1 → python_benedict-0.34.0}/MANIFEST.in +0 -0
  13. {python-benedict-0.33.1 → python_benedict-0.34.0}/benedict/__init__.py +0 -0
  14. {python-benedict-0.33.1 → python_benedict-0.34.0}/benedict/core/__init__.py +0 -0
  15. {python-benedict-0.33.1 → python_benedict-0.34.0}/benedict/core/clone.py +0 -0
  16. {python-benedict-0.33.1 → python_benedict-0.34.0}/benedict/core/dump.py +0 -0
  17. {python-benedict-0.33.1 → python_benedict-0.34.0}/benedict/core/filter.py +0 -0
  18. {python-benedict-0.33.1 → python_benedict-0.34.0}/benedict/core/find.py +0 -0
  19. {python-benedict-0.33.1 → python_benedict-0.34.0}/benedict/core/flatten.py +0 -0
  20. {python-benedict-0.33.1 → python_benedict-0.34.0}/benedict/core/groupby.py +0 -0
  21. {python-benedict-0.33.1 → python_benedict-0.34.0}/benedict/core/invert.py +0 -0
  22. {python-benedict-0.33.1 → python_benedict-0.34.0}/benedict/core/items_sorted.py +0 -0
  23. {python-benedict-0.33.1 → python_benedict-0.34.0}/benedict/core/keylists.py +0 -0
  24. {python-benedict-0.33.1 → python_benedict-0.34.0}/benedict/core/keypaths.py +0 -0
  25. {python-benedict-0.33.1 → python_benedict-0.34.0}/benedict/core/match.py +0 -0
  26. {python-benedict-0.33.1 → python_benedict-0.34.0}/benedict/core/merge.py +0 -0
  27. {python-benedict-0.33.1 → python_benedict-0.34.0}/benedict/core/move.py +0 -0
  28. {python-benedict-0.33.1 → python_benedict-0.34.0}/benedict/core/nest.py +0 -0
  29. {python-benedict-0.33.1 → python_benedict-0.34.0}/benedict/core/remove.py +0 -0
  30. {python-benedict-0.33.1 → python_benedict-0.34.0}/benedict/core/rename.py +0 -0
  31. {python-benedict-0.33.1 → python_benedict-0.34.0}/benedict/core/search.py +0 -0
  32. {python-benedict-0.33.1 → python_benedict-0.34.0}/benedict/core/standardize.py +0 -0
  33. {python-benedict-0.33.1 → python_benedict-0.34.0}/benedict/core/subset.py +0 -0
  34. {python-benedict-0.33.1 → python_benedict-0.34.0}/benedict/core/swap.py +0 -0
  35. {python-benedict-0.33.1 → python_benedict-0.34.0}/benedict/core/traverse.py +0 -0
  36. {python-benedict-0.33.1 → python_benedict-0.34.0}/benedict/core/unflatten.py +0 -0
  37. {python-benedict-0.33.1 → python_benedict-0.34.0}/benedict/core/unique.py +0 -0
  38. {python-benedict-0.33.1 → python_benedict-0.34.0}/benedict/dicts/base/__init__.py +0 -0
  39. {python-benedict-0.33.1 → python_benedict-0.34.0}/benedict/dicts/base/base_dict.py +0 -0
  40. {python-benedict-0.33.1 → python_benedict-0.34.0}/benedict/dicts/io/__init__.py +0 -0
  41. {python-benedict-0.33.1 → python_benedict-0.34.0}/benedict/dicts/io/io_dict.py +0 -0
  42. {python-benedict-0.33.1 → python_benedict-0.34.0}/benedict/dicts/io/io_util.py +0 -0
  43. {python-benedict-0.33.1 → python_benedict-0.34.0}/benedict/dicts/keyattr/__init__.py +0 -0
  44. {python-benedict-0.33.1 → python_benedict-0.34.0}/benedict/dicts/keyattr/keyattr_dict.py +0 -0
  45. {python-benedict-0.33.1 → python_benedict-0.34.0}/benedict/dicts/keylist/__init__.py +0 -0
  46. {python-benedict-0.33.1 → python_benedict-0.34.0}/benedict/dicts/keylist/keylist_util.py +0 -0
  47. {python-benedict-0.33.1 → python_benedict-0.34.0}/benedict/dicts/keypath/__init__.py +0 -0
  48. {python-benedict-0.33.1 → python_benedict-0.34.0}/benedict/dicts/keypath/keypath_dict.py +0 -0
  49. {python-benedict-0.33.1 → python_benedict-0.34.0}/benedict/dicts/parse/__init__.py +0 -0
  50. {python-benedict-0.33.1 → python_benedict-0.34.0}/benedict/dicts/parse/parse_dict.py +0 -0
  51. {python-benedict-0.33.1 → python_benedict-0.34.0}/benedict/dicts/parse/parse_util.py +0 -0
  52. {python-benedict-0.33.1 → python_benedict-0.34.0}/benedict/exceptions.py +0 -0
  53. {python-benedict-0.33.1 → python_benedict-0.34.0}/benedict/extras.py +0 -0
  54. {python-benedict-0.33.1 → python_benedict-0.34.0}/benedict/serializers/__init__.py +0 -0
  55. {python-benedict-0.33.1 → python_benedict-0.34.0}/benedict/serializers/abstract.py +0 -0
  56. {python-benedict-0.33.1 → python_benedict-0.34.0}/benedict/serializers/base64.py +0 -0
  57. {python-benedict-0.33.1 → python_benedict-0.34.0}/benedict/serializers/cli.py +0 -0
  58. {python-benedict-0.33.1 → python_benedict-0.34.0}/benedict/serializers/csv.py +0 -0
  59. {python-benedict-0.33.1 → python_benedict-0.34.0}/benedict/serializers/html.py +0 -0
  60. {python-benedict-0.33.1 → python_benedict-0.34.0}/benedict/serializers/ini.py +0 -0
  61. {python-benedict-0.33.1 → python_benedict-0.34.0}/benedict/serializers/json.py +0 -0
  62. {python-benedict-0.33.1 → python_benedict-0.34.0}/benedict/serializers/pickle.py +0 -0
  63. {python-benedict-0.33.1 → python_benedict-0.34.0}/benedict/serializers/plist.py +0 -0
  64. {python-benedict-0.33.1 → python_benedict-0.34.0}/benedict/serializers/query_string.py +0 -0
  65. {python-benedict-0.33.1 → python_benedict-0.34.0}/benedict/serializers/toml.py +0 -0
  66. {python-benedict-0.33.1 → python_benedict-0.34.0}/benedict/serializers/xls.py +0 -0
  67. {python-benedict-0.33.1 → python_benedict-0.34.0}/benedict/serializers/xml.py +0 -0
  68. {python-benedict-0.33.1 → python_benedict-0.34.0}/benedict/serializers/yaml.py +0 -0
  69. {python-benedict-0.33.1 → python_benedict-0.34.0}/benedict/utils/__init__.py +0 -0
  70. {python-benedict-0.33.1 → python_benedict-0.34.0}/benedict/utils/type_util.py +0 -0
  71. {python-benedict-0.33.1 → python_benedict-0.34.0}/python_benedict.egg-info/SOURCES.txt +0 -0
  72. {python-benedict-0.33.1 → python_benedict-0.34.0}/python_benedict.egg-info/dependency_links.txt +0 -0
  73. {python-benedict-0.33.1 → python_benedict-0.34.0}/python_benedict.egg-info/requires.txt +0 -0
  74. {python-benedict-0.33.1 → python_benedict-0.34.0}/python_benedict.egg-info/top_level.txt +0 -0
  75. {python-benedict-0.33.1 → python_benedict-0.34.0}/setup.cfg +0 -0
  76. {python-benedict-0.33.1 → python_benedict-0.34.0}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-benedict
3
- Version: 0.33.1
3
+ Version: 0.34.0
4
4
  Summary: python-benedict is a dict subclass with keylist/keypath/keyattr support, normalized I/O operations (base64, csv, ini, json, pickle, plist, query-string, toml, xls, xml, yaml) and many utilities... for humans, obviously.
5
5
  Author-email: Fabio Caccamo <fabio.caccamo@gmail.com>
6
6
  Maintainer-email: Fabio Caccamo <fabio.caccamo@gmail.com>
@@ -47,11 +47,10 @@ Classifier: License :: OSI Approved :: MIT License
47
47
  Classifier: Natural Language :: English
48
48
  Classifier: Operating System :: OS Independent
49
49
  Classifier: Programming Language :: Python :: 3
50
- Classifier: Programming Language :: Python :: 3.8
51
- Classifier: Programming Language :: Python :: 3.9
52
50
  Classifier: Programming Language :: Python :: 3.10
53
51
  Classifier: Programming Language :: Python :: 3.11
54
52
  Classifier: Programming Language :: Python :: 3.12
53
+ Classifier: Programming Language :: Python :: 3.13
55
54
  Classifier: Topic :: Education :: Testing
56
55
  Classifier: Topic :: Software Development :: Build Tools
57
56
  Classifier: Topic :: System :: Filesystems
@@ -89,7 +88,7 @@ Requires-Dist: pyyaml<7.0,>=6.0; extra == "yaml"
89
88
  [![](https://img.shields.io/pypi/pyversions/python-benedict.svg?color=blue&logo=python&logoColor=white)](https://www.python.org/)
90
89
  [![](https://img.shields.io/pypi/v/python-benedict.svg?color=blue&logo=pypi&logoColor=white)](https://pypi.org/project/python-benedict/)
91
90
  [![](https://static.pepy.tech/badge/python-benedict/month)](https://pepy.tech/project/python-benedict)
92
- [![](https://img.shields.io/github/stars/fabiocaccamo/python-benedict?logo=github)](https://github.com/fabiocaccamo/python-benedict/stargazers)
91
+ [![](https://img.shields.io/github/stars/fabiocaccamo/python-benedict?logo=github&style=flat)](https://github.com/fabiocaccamo/python-benedict/stargazers)
93
92
  [![](https://img.shields.io/pypi/l/python-benedict.svg?color=blue)](https://github.com/fabiocaccamo/python-benedict/blob/main/LICENSE.txt)
94
93
 
95
94
  [![](https://results.pre-commit.ci/badge/github/fabiocaccamo/python-benedict/main.svg)](https://results.pre-commit.ci/latest/github/fabiocaccamo/python-benedict/main)
@@ -121,7 +120,7 @@ python-benedict is a dict subclass with **keylist/keypath/keyattr** support, **I
121
120
  - [Usage](#usage)
122
121
  - [Basics](#basics)
123
122
  - [Keyattr](#keyattr) `my_dict.x.y.z`
124
- - [Keylist](#keylist) `my_dict["x", "y", "z"]`
123
+ - [Keylist](#keylist) `my_dict[["x", "y", "z"]]`
125
124
  - [Keypath](#keypath) `my_dict["x.y.z"]`
126
125
  - [Custom keypath separator](#custom-keypath-separator)
127
126
  - [Change keypath separator](#change-keypath-separator)
@@ -224,16 +223,16 @@ Wherever a **key** is used, it is possible to use also a **list (or a tuple) of
224
223
  d = benedict()
225
224
 
226
225
  # set values by keys list
227
- d["profile", "firstname"] = "Fabio"
228
- d["profile", "lastname"] = "Caccamo"
226
+ d[["profile", "firstname"]] = "Fabio"
227
+ d[["profile", "lastname"]] = "Caccamo"
229
228
  print(d) # -> { "profile":{ "firstname":"Fabio", "lastname":"Caccamo" } }
230
229
  print(d["profile"]) # -> { "firstname":"Fabio", "lastname":"Caccamo" }
231
230
 
232
231
  # check if keypath exists in dict
233
- print(["profile", "lastname"] in d) # -> True
232
+ print([["profile", "lastname"]] in d) # -> True
234
233
 
235
234
  # delete value by keys list
236
- del d["profile", "lastname"]
235
+ del d[["profile", "lastname"]]
237
236
  print(d["profile"]) # -> { "firstname":"Fabio" }
238
237
  ```
239
238
 
@@ -1,7 +1,7 @@
1
1
  [![](https://img.shields.io/pypi/pyversions/python-benedict.svg?color=blue&logo=python&logoColor=white)](https://www.python.org/)
2
2
  [![](https://img.shields.io/pypi/v/python-benedict.svg?color=blue&logo=pypi&logoColor=white)](https://pypi.org/project/python-benedict/)
3
3
  [![](https://static.pepy.tech/badge/python-benedict/month)](https://pepy.tech/project/python-benedict)
4
- [![](https://img.shields.io/github/stars/fabiocaccamo/python-benedict?logo=github)](https://github.com/fabiocaccamo/python-benedict/stargazers)
4
+ [![](https://img.shields.io/github/stars/fabiocaccamo/python-benedict?logo=github&style=flat)](https://github.com/fabiocaccamo/python-benedict/stargazers)
5
5
  [![](https://img.shields.io/pypi/l/python-benedict.svg?color=blue)](https://github.com/fabiocaccamo/python-benedict/blob/main/LICENSE.txt)
6
6
 
7
7
  [![](https://results.pre-commit.ci/badge/github/fabiocaccamo/python-benedict/main.svg)](https://results.pre-commit.ci/latest/github/fabiocaccamo/python-benedict/main)
@@ -33,7 +33,7 @@ python-benedict is a dict subclass with **keylist/keypath/keyattr** support, **I
33
33
  - [Usage](#usage)
34
34
  - [Basics](#basics)
35
35
  - [Keyattr](#keyattr) `my_dict.x.y.z`
36
- - [Keylist](#keylist) `my_dict["x", "y", "z"]`
36
+ - [Keylist](#keylist) `my_dict[["x", "y", "z"]]`
37
37
  - [Keypath](#keypath) `my_dict["x.y.z"]`
38
38
  - [Custom keypath separator](#custom-keypath-separator)
39
39
  - [Change keypath separator](#change-keypath-separator)
@@ -136,16 +136,16 @@ Wherever a **key** is used, it is possible to use also a **list (or a tuple) of
136
136
  d = benedict()
137
137
 
138
138
  # set values by keys list
139
- d["profile", "firstname"] = "Fabio"
140
- d["profile", "lastname"] = "Caccamo"
139
+ d[["profile", "firstname"]] = "Fabio"
140
+ d[["profile", "lastname"]] = "Caccamo"
141
141
  print(d) # -> { "profile":{ "firstname":"Fabio", "lastname":"Caccamo" } }
142
142
  print(d["profile"]) # -> { "firstname":"Fabio", "lastname":"Caccamo" }
143
143
 
144
144
  # check if keypath exists in dict
145
- print(["profile", "lastname"] in d) # -> True
145
+ print([["profile", "lastname"]] in d) # -> True
146
146
 
147
147
  # delete value by keys list
148
- del d["profile", "lastname"]
148
+ del d[["profile", "lastname"]]
149
149
  print(d["profile"]) # -> { "firstname":"Fabio" }
150
150
  ```
151
151
 
@@ -0,0 +1,55 @@
1
+ def _clean_dict(d, strings, collections):
2
+ keys = list(d.keys())
3
+ for key in keys:
4
+ d[key] = _clean_value(d[key], strings=strings, collections=collections)
5
+ if d[key] is None:
6
+ del d[key]
7
+ return d
8
+
9
+
10
+ def _clean_list(ls, strings, collections):
11
+ for i in range(len(ls) - 1, -1, -1):
12
+ ls[i] = _clean_value(ls[i], strings=strings, collections=collections)
13
+ if ls[i] is None:
14
+ ls.pop(i)
15
+ return ls
16
+
17
+
18
+ def _clean_set(values, strings, collections):
19
+ return {
20
+ value
21
+ for value in values
22
+ if _clean_value(value, strings=strings, collections=collections) is not None
23
+ }
24
+
25
+
26
+ def _clean_str(s, strings, collections):
27
+ return s if s and s.strip() else None
28
+
29
+
30
+ def _clean_tuple(values, strings, collections):
31
+ return tuple(
32
+ value
33
+ for value in values
34
+ if _clean_value(value, strings=strings, collections=collections) is not None
35
+ )
36
+
37
+
38
+ def _clean_value(value, strings, collections):
39
+ if value is None:
40
+ return value
41
+ elif isinstance(value, list) and collections:
42
+ value = _clean_list(value, strings=strings, collections=collections) or None
43
+ elif isinstance(value, dict) and collections:
44
+ value = _clean_dict(value, strings=strings, collections=collections) or None
45
+ elif isinstance(value, set) and collections:
46
+ value = _clean_set(value, strings=strings, collections=collections) or None
47
+ elif isinstance(value, str) and strings:
48
+ value = _clean_str(value, strings=strings, collections=collections) or None
49
+ elif isinstance(value, tuple) and collections:
50
+ value = _clean_tuple(value, strings=strings, collections=collections) or None
51
+ return value
52
+
53
+
54
+ def clean(d, strings=True, collections=True):
55
+ return _clean_dict(d, strings=strings, collections=collections)
@@ -26,6 +26,7 @@ from benedict.dicts.io import IODict
26
26
  from benedict.dicts.keyattr import KeyattrDict
27
27
  from benedict.dicts.keylist import KeylistDict
28
28
  from benedict.dicts.keypath import KeypathDict
29
+ from benedict.dicts.keypath import keypath_util
29
30
  from benedict.dicts.parse import ParseDict
30
31
  from benedict.serializers import JSONSerializer, YAMLSerializer
31
32
 
@@ -219,7 +220,10 @@ class benedict(KeyattrDict, KeypathDict, IODict, ParseDict):
219
220
  If overwrite is False, existing values will not be overwritten.
220
221
  If concat is True, list values will be concatenated together.
221
222
  """
222
- _merge(self, other, *args, **kwargs)
223
+ others = [other] + list(args)
224
+ for other in others:
225
+ keypath_util.check_keys(other, self._keypath_separator)
226
+ _merge(self, *others, **kwargs)
223
227
 
224
228
  def move(self, key_src, key_dest):
225
229
  """
@@ -8,7 +8,7 @@ class KeylistDict(BaseDict):
8
8
  super().__init__(*args, **kwargs)
9
9
 
10
10
  def __contains__(self, key):
11
- if type_util.is_list_or_tuple(key):
11
+ if type_util.is_list(key):
12
12
  return self._contains_by_keys(key)
13
13
  return super().__contains__(key)
14
14
 
@@ -19,7 +19,7 @@ class KeylistDict(BaseDict):
19
19
  return False
20
20
 
21
21
  def __delitem__(self, key):
22
- if type_util.is_list_or_tuple(key):
22
+ if type_util.is_list(key):
23
23
  self._delitem_by_keys(key)
24
24
  return
25
25
  super().__delitem__(key)
@@ -35,7 +35,7 @@ class KeylistDict(BaseDict):
35
35
  raise KeyError(f"Invalid keys: {keys!r}")
36
36
 
37
37
  def __getitem__(self, key):
38
- if type_util.is_list_or_tuple(key):
38
+ if type_util.is_list(key):
39
39
  return self._getitem_by_keys(key)
40
40
  return super().__getitem__(key)
41
41
 
@@ -46,7 +46,7 @@ class KeylistDict(BaseDict):
46
46
  raise KeyError(f"Invalid keys: {keys!r}")
47
47
 
48
48
  def __setitem__(self, key, value):
49
- if type_util.is_list_or_tuple(key):
49
+ if type_util.is_list(key):
50
50
  self._setitem_by_keys(key, value)
51
51
  return
52
52
  super().__setitem__(key, value)
@@ -55,7 +55,7 @@ class KeylistDict(BaseDict):
55
55
  keylist_util.set_item(self, keys, value)
56
56
 
57
57
  def get(self, key, default=None):
58
- if type_util.is_list_or_tuple(key):
58
+ if type_util.is_list(key):
59
59
  return self._get_by_keys(key, default)
60
60
  return super().get(key, default)
61
61
 
@@ -68,7 +68,7 @@ class KeylistDict(BaseDict):
68
68
  return default
69
69
 
70
70
  def pop(self, key, *args):
71
- if type_util.is_list_or_tuple(key):
71
+ if type_util.is_list(key):
72
72
  return self._pop_by_keys(key, *args)
73
73
  return super().pop(key, *args)
74
74
 
@@ -26,7 +26,7 @@ def parse_keys(keypath, separator):
26
26
  """
27
27
  Parse keys from keylist or keypath using the given separator.
28
28
  """
29
- if type_util.is_list_or_tuple(keypath):
29
+ if type_util.is_list(keypath):
30
30
  keys = []
31
31
  for key in keypath:
32
32
  keys += parse_keys(key, separator)
@@ -8,4 +8,4 @@ __description__ = (
8
8
  __email__ = "fabio.caccamo@gmail.com"
9
9
  __license__ = "MIT"
10
10
  __title__ = "benedict"
11
- __version__ = "0.33.1"
11
+ __version__ = "0.34.0"
@@ -77,11 +77,10 @@ classifiers = [
77
77
  "Natural Language :: English",
78
78
  "Operating System :: OS Independent",
79
79
  "Programming Language :: Python :: 3",
80
- "Programming Language :: Python :: 3.8",
81
- "Programming Language :: Python :: 3.9",
82
80
  "Programming Language :: Python :: 3.10",
83
81
  "Programming Language :: Python :: 3.11",
84
82
  "Programming Language :: Python :: 3.12",
83
+ "Programming Language :: Python :: 3.13",
85
84
  "Topic :: Education :: Testing",
86
85
  "Topic :: Software Development :: Build Tools",
87
86
  "Topic :: System :: Filesystems",
@@ -167,11 +166,13 @@ exclude = '''
167
166
  '''
168
167
 
169
168
  [tool.ruff]
170
- ignore = ["B905", "E501"]
171
169
  line-length = 88
170
+
171
+ [tool.ruff.lint]
172
+ ignore = ["B905", "E501"]
172
173
  select = ["B", "B9", "C", "E", "F", "W"]
173
174
 
174
- [tool.ruff.mccabe]
175
+ [tool.ruff.lint.mccabe]
175
176
  max-complexity = 10
176
177
 
177
178
  [tool.setuptools.packages.find]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-benedict
3
- Version: 0.33.1
3
+ Version: 0.34.0
4
4
  Summary: python-benedict is a dict subclass with keylist/keypath/keyattr support, normalized I/O operations (base64, csv, ini, json, pickle, plist, query-string, toml, xls, xml, yaml) and many utilities... for humans, obviously.
5
5
  Author-email: Fabio Caccamo <fabio.caccamo@gmail.com>
6
6
  Maintainer-email: Fabio Caccamo <fabio.caccamo@gmail.com>
@@ -47,11 +47,10 @@ Classifier: License :: OSI Approved :: MIT License
47
47
  Classifier: Natural Language :: English
48
48
  Classifier: Operating System :: OS Independent
49
49
  Classifier: Programming Language :: Python :: 3
50
- Classifier: Programming Language :: Python :: 3.8
51
- Classifier: Programming Language :: Python :: 3.9
52
50
  Classifier: Programming Language :: Python :: 3.10
53
51
  Classifier: Programming Language :: Python :: 3.11
54
52
  Classifier: Programming Language :: Python :: 3.12
53
+ Classifier: Programming Language :: Python :: 3.13
55
54
  Classifier: Topic :: Education :: Testing
56
55
  Classifier: Topic :: Software Development :: Build Tools
57
56
  Classifier: Topic :: System :: Filesystems
@@ -89,7 +88,7 @@ Requires-Dist: pyyaml<7.0,>=6.0; extra == "yaml"
89
88
  [![](https://img.shields.io/pypi/pyversions/python-benedict.svg?color=blue&logo=python&logoColor=white)](https://www.python.org/)
90
89
  [![](https://img.shields.io/pypi/v/python-benedict.svg?color=blue&logo=pypi&logoColor=white)](https://pypi.org/project/python-benedict/)
91
90
  [![](https://static.pepy.tech/badge/python-benedict/month)](https://pepy.tech/project/python-benedict)
92
- [![](https://img.shields.io/github/stars/fabiocaccamo/python-benedict?logo=github)](https://github.com/fabiocaccamo/python-benedict/stargazers)
91
+ [![](https://img.shields.io/github/stars/fabiocaccamo/python-benedict?logo=github&style=flat)](https://github.com/fabiocaccamo/python-benedict/stargazers)
93
92
  [![](https://img.shields.io/pypi/l/python-benedict.svg?color=blue)](https://github.com/fabiocaccamo/python-benedict/blob/main/LICENSE.txt)
94
93
 
95
94
  [![](https://results.pre-commit.ci/badge/github/fabiocaccamo/python-benedict/main.svg)](https://results.pre-commit.ci/latest/github/fabiocaccamo/python-benedict/main)
@@ -121,7 +120,7 @@ python-benedict is a dict subclass with **keylist/keypath/keyattr** support, **I
121
120
  - [Usage](#usage)
122
121
  - [Basics](#basics)
123
122
  - [Keyattr](#keyattr) `my_dict.x.y.z`
124
- - [Keylist](#keylist) `my_dict["x", "y", "z"]`
123
+ - [Keylist](#keylist) `my_dict[["x", "y", "z"]]`
125
124
  - [Keypath](#keypath) `my_dict["x.y.z"]`
126
125
  - [Custom keypath separator](#custom-keypath-separator)
127
126
  - [Change keypath separator](#change-keypath-separator)
@@ -224,16 +223,16 @@ Wherever a **key** is used, it is possible to use also a **list (or a tuple) of
224
223
  d = benedict()
225
224
 
226
225
  # set values by keys list
227
- d["profile", "firstname"] = "Fabio"
228
- d["profile", "lastname"] = "Caccamo"
226
+ d[["profile", "firstname"]] = "Fabio"
227
+ d[["profile", "lastname"]] = "Caccamo"
229
228
  print(d) # -> { "profile":{ "firstname":"Fabio", "lastname":"Caccamo" } }
230
229
  print(d["profile"]) # -> { "firstname":"Fabio", "lastname":"Caccamo" }
231
230
 
232
231
  # check if keypath exists in dict
233
- print(["profile", "lastname"] in d) # -> True
232
+ print([["profile", "lastname"]] in d) # -> True
234
233
 
235
234
  # delete value by keys list
236
- del d["profile", "lastname"]
235
+ del d[["profile", "lastname"]]
237
236
  print(d["profile"]) # -> { "firstname":"Fabio" }
238
237
  ```
239
238
 
@@ -1,19 +0,0 @@
1
- from benedict.utils import type_util
2
-
3
-
4
- def _clean_item(d, key, strings, collections):
5
- value = d.get(key, None)
6
- if not value:
7
- del_none = value is None
8
- del_string = strings and type_util.is_string(value)
9
- del_collection = collections and type_util.is_collection(value)
10
- return any([del_none, del_string, del_collection])
11
-
12
- return False
13
-
14
-
15
- def clean(d, strings=True, collections=True):
16
- keys = list(d.keys())
17
- for key in keys:
18
- if _clean_item(d, key, strings, collections):
19
- del d[key]