easydotdict 1.0.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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 draganoxfool
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,76 @@
1
+ Metadata-Version: 2.4
2
+ Name: easydotdict
3
+ Version: 1.0.0
4
+ Summary: Effortless nested dictionary access — dot notation, safe missing keys, auto-vivification, and more
5
+ Author-email: draganoxfool <draganogaming1@gmail.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/draganoxfool/Easydotdict
8
+ Project-URL: Source, https://github.com/draganoxfool/Easydotdict
9
+ Classifier: Development Status :: 5 - Production/Stable
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.8
14
+ Classifier: Programming Language :: Python :: 3.9
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
20
+ Requires-Python: >=3.8
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Dynamic: license-file
24
+
25
+ # easydotdict
26
+
27
+ Make nested dictionaries effortless — dot-notation access, safe missing-key handling, auto-vivification, deep path operations, and pretty-printing. Pure Python, no dependencies.
28
+
29
+ ```python
30
+ from easydotdict import EasyDict
31
+
32
+ d = EasyDict({'user': {'profile': {'name': 'Alice'}}})
33
+ print(d.user.profile.name) # Alice
34
+ print(d['user'].profile.name) # same
35
+ print(d.user.email) # None (safe, no error)
36
+
37
+ d.config.database.host = 'localhost' # auto-creates path
38
+ d.put('server.port', 8080) # or use path string
39
+ print(d.dig('user.name')) # Alice (deep path getter)
40
+
41
+ flat = d.flatten() # {'user.profile.name': 'Alice', ...}
42
+ restored = EasyDict.unflatten(flat) # reverse
43
+
44
+ d.merge({'settings': {'debug': True}}) # deep merge
45
+ print(d) # indented JSON
46
+ ```
47
+
48
+ ## Features
49
+
50
+ - **Dot notation** — `d.user.profile.name` instead of `d['user']['profile']['name']`
51
+ - **Dual access** — dot and bracket notation work interchangeably
52
+ - **Safe access** — `d.missing` returns `None`, no `KeyError`/`AttributeError`
53
+ - **Auto-vivification** — `d.a.b.c = value` auto-creates intermediate structures
54
+ - **Deep path operations** — `dig`, `put`, `has` with dot-separated strings
55
+ - **Flatten / Unflatten** — recursive flatten and restore with `flatten()` and `unflatten()`
56
+ - **Deep merge** — `update()` and `merge()` merge recursively, preserving existing keys
57
+ - **Clone** — `clone()` returns a deep independent copy
58
+ - **Empty check** — `is_empty()` checks if the dict has no keys
59
+ - **Auto-conversion** — nested `dict`s and `list`s containing `dict`s are wrapped automatically
60
+ - **Pretty-print** — `print(d)` outputs indented JSON
61
+ - **`to_dict()`** — recursively converts back to plain `dict`s and `list`s
62
+ - **Pure Python** — standard library only, Python 3.8+
63
+
64
+ ## Install
65
+
66
+ ```bash
67
+ pip install easydotdict
68
+ ```
69
+
70
+ ## Documentation
71
+
72
+ See [docs.md](docs.md) for full API reference, edge cases, and examples.
73
+
74
+ ## License
75
+
76
+ MIT
@@ -0,0 +1,52 @@
1
+ # easydotdict
2
+
3
+ Make nested dictionaries effortless — dot-notation access, safe missing-key handling, auto-vivification, deep path operations, and pretty-printing. Pure Python, no dependencies.
4
+
5
+ ```python
6
+ from easydotdict import EasyDict
7
+
8
+ d = EasyDict({'user': {'profile': {'name': 'Alice'}}})
9
+ print(d.user.profile.name) # Alice
10
+ print(d['user'].profile.name) # same
11
+ print(d.user.email) # None (safe, no error)
12
+
13
+ d.config.database.host = 'localhost' # auto-creates path
14
+ d.put('server.port', 8080) # or use path string
15
+ print(d.dig('user.name')) # Alice (deep path getter)
16
+
17
+ flat = d.flatten() # {'user.profile.name': 'Alice', ...}
18
+ restored = EasyDict.unflatten(flat) # reverse
19
+
20
+ d.merge({'settings': {'debug': True}}) # deep merge
21
+ print(d) # indented JSON
22
+ ```
23
+
24
+ ## Features
25
+
26
+ - **Dot notation** — `d.user.profile.name` instead of `d['user']['profile']['name']`
27
+ - **Dual access** — dot and bracket notation work interchangeably
28
+ - **Safe access** — `d.missing` returns `None`, no `KeyError`/`AttributeError`
29
+ - **Auto-vivification** — `d.a.b.c = value` auto-creates intermediate structures
30
+ - **Deep path operations** — `dig`, `put`, `has` with dot-separated strings
31
+ - **Flatten / Unflatten** — recursive flatten and restore with `flatten()` and `unflatten()`
32
+ - **Deep merge** — `update()` and `merge()` merge recursively, preserving existing keys
33
+ - **Clone** — `clone()` returns a deep independent copy
34
+ - **Empty check** — `is_empty()` checks if the dict has no keys
35
+ - **Auto-conversion** — nested `dict`s and `list`s containing `dict`s are wrapped automatically
36
+ - **Pretty-print** — `print(d)` outputs indented JSON
37
+ - **`to_dict()`** — recursively converts back to plain `dict`s and `list`s
38
+ - **Pure Python** — standard library only, Python 3.8+
39
+
40
+ ## Install
41
+
42
+ ```bash
43
+ pip install easydotdict
44
+ ```
45
+
46
+ ## Documentation
47
+
48
+ See [docs.md](docs.md) for full API reference, edge cases, and examples.
49
+
50
+ ## License
51
+
52
+ MIT
@@ -0,0 +1,4 @@
1
+ from .easydotdict import EasyDict
2
+
3
+ __version__ = "1.0.0"
4
+ __all__ = ["EasyDict", "__version__"]
@@ -0,0 +1,251 @@
1
+ import json
2
+
3
+
4
+ class _Missing:
5
+ def __init__(self, parent, key):
6
+ object.__setattr__(self, '_parent', parent)
7
+ object.__setattr__(self, '_key', key)
8
+
9
+ def __getattr__(self, key):
10
+ if key.startswith('_'):
11
+ raise AttributeError(key)
12
+ return _Missing(self, key)
13
+
14
+ def __setattr__(self, key, value):
15
+ if key.startswith('_'):
16
+ object.__setattr__(self, key, value)
17
+ else:
18
+ self._materialize().__setitem__(key, value)
19
+
20
+ def __setitem__(self, key, value):
21
+ self._materialize().__setitem__(key, value)
22
+
23
+ def __delattr__(self, key):
24
+ self._materialize().__delitem__(key)
25
+
26
+ def __bool__(self):
27
+ return False
28
+
29
+ def __eq__(self, other):
30
+ if other is None:
31
+ return True
32
+ return NotImplemented
33
+
34
+ def __ne__(self, other):
35
+ if other is None:
36
+ return False
37
+ return NotImplemented
38
+
39
+ def __repr__(self):
40
+ return 'None'
41
+
42
+ def __str__(self):
43
+ return 'None'
44
+
45
+ def _materialize(self):
46
+ path = []
47
+ obj = self
48
+ while isinstance(obj, _Missing):
49
+ path.append(obj._key)
50
+ obj = obj._parent
51
+ current = obj
52
+ for key in reversed(path):
53
+ if key not in current:
54
+ current[key] = EasyDict()
55
+ current = current[key]
56
+ return current
57
+
58
+
59
+ def _wrap(value):
60
+ if isinstance(value, dict) and not isinstance(value, EasyDict):
61
+ return EasyDict(value)
62
+ elif isinstance(value, list):
63
+ return _convert_list(value)
64
+ return value
65
+
66
+
67
+ def _convert_list(lst):
68
+ result = []
69
+ for item in lst:
70
+ if isinstance(item, dict) and not isinstance(item, EasyDict):
71
+ result.append(EasyDict(item))
72
+ elif isinstance(item, list):
73
+ result.append(_convert_list(item))
74
+ else:
75
+ result.append(item)
76
+ return result
77
+
78
+
79
+ def _deep_merge(target, source):
80
+ for key, value in source.items():
81
+ if key in target and isinstance(target[key], EasyDict) and isinstance(value, dict):
82
+ _deep_merge(target[key], value)
83
+ else:
84
+ target[key] = value
85
+
86
+
87
+ class EasyDict(dict):
88
+ def __init__(self, *args, **kwargs):
89
+ super().__init__(*args, **kwargs)
90
+ for key, value in list(super().items()):
91
+ if isinstance(value, dict) and not isinstance(value, EasyDict):
92
+ super().__setitem__(key, EasyDict(value))
93
+ elif isinstance(value, list):
94
+ super().__setitem__(key, _convert_list(value))
95
+
96
+ def __getattribute__(self, key):
97
+ if key.startswith('_'):
98
+ return super().__getattribute__(key)
99
+ try:
100
+ return dict.__getitem__(self, key)
101
+ except KeyError:
102
+ return super().__getattribute__(key)
103
+
104
+ def __getattr__(self, key):
105
+ return _Missing(self, key)
106
+
107
+ def __setattr__(self, key, value):
108
+ dict.__setitem__(self, key, _wrap(value))
109
+
110
+ def __delattr__(self, key):
111
+ try:
112
+ dict.__delitem__(self, key)
113
+ except KeyError:
114
+ raise AttributeError(key)
115
+
116
+ def __getitem__(self, key):
117
+ try:
118
+ return dict.__getitem__(self, key)
119
+ except KeyError:
120
+ return None
121
+
122
+ def __setitem__(self, key, value):
123
+ dict.__setitem__(self, key, _wrap(value))
124
+
125
+ def __repr__(self):
126
+ return json.dumps(self.to_dict(), indent=2, default=str)
127
+
128
+ def __str__(self):
129
+ return self.__repr__()
130
+
131
+ def to_dict(self):
132
+ result = {}
133
+ for key, value in self.items():
134
+ if isinstance(value, EasyDict):
135
+ result[key] = value.to_dict()
136
+ elif isinstance(value, list):
137
+ result[key] = [
138
+ item.to_dict() if isinstance(item, EasyDict) else item
139
+ for item in value
140
+ ]
141
+ else:
142
+ result[key] = value
143
+ return result
144
+
145
+ def copy(self):
146
+ return self.clone()
147
+
148
+ def clone(self):
149
+ return EasyDict(self.to_dict())
150
+
151
+ def update(self, other=None, **kwargs):
152
+ if other is not None:
153
+ if hasattr(other, 'items'):
154
+ _deep_merge(self, other)
155
+ else:
156
+ for k, v in other:
157
+ self[k] = v
158
+ for k, v in kwargs.items():
159
+ _deep_merge_items = {k: v}
160
+ _deep_merge(self, _deep_merge_items)
161
+
162
+ def merge(self, other):
163
+ _deep_merge(self, other)
164
+ return self
165
+
166
+ def get(self, key, default=None):
167
+ if key in self:
168
+ return dict.__getitem__(self, key)
169
+ return default
170
+
171
+ def dig(self, path):
172
+ keys = path.split('.')
173
+ current = self
174
+ for key in keys:
175
+ if isinstance(current, dict):
176
+ try:
177
+ current = dict.__getitem__(current, key)
178
+ except KeyError:
179
+ return None
180
+ else:
181
+ return None
182
+ return current
183
+
184
+ def put(self, path, value):
185
+ keys = path.split('.')
186
+ current = self
187
+ for key in keys[:-1]:
188
+ if key not in current:
189
+ current[key] = EasyDict()
190
+ current = current[key]
191
+ current[keys[-1]] = value
192
+
193
+ def has(self, path):
194
+ keys = path.split('.')
195
+ current = self
196
+ for key in keys:
197
+ if isinstance(current, dict) and key in current:
198
+ current = dict.__getitem__(current, key)
199
+ else:
200
+ return False
201
+ return True
202
+
203
+ def flatten(self, prefix=''):
204
+ result = {}
205
+ for key, value in self.items():
206
+ full_key = f'{prefix}.{key}' if prefix else str(key)
207
+ if isinstance(value, EasyDict):
208
+ result.update(value.flatten(prefix=full_key))
209
+ elif isinstance(value, list):
210
+ for i, item in enumerate(value):
211
+ item_key = f'{full_key}.{i}'
212
+ if isinstance(item, EasyDict):
213
+ result.update(item.flatten(prefix=item_key))
214
+ else:
215
+ result[item_key] = item
216
+ else:
217
+ result[full_key] = value
218
+ return result
219
+
220
+ @classmethod
221
+ def unflatten(cls, data):
222
+ root = {}
223
+ for dotted_key, value in data.items():
224
+ parts = dotted_key.split('.')
225
+ current = root
226
+ for i, part in enumerate(parts):
227
+ is_last = (i == len(parts) - 1)
228
+ if is_last:
229
+ current[part] = value
230
+ else:
231
+ if part not in current:
232
+ current[part] = {}
233
+ current = current[part]
234
+ return cls(cls._lists_from_dict(root))
235
+
236
+ @staticmethod
237
+ def _lists_from_dict(d):
238
+ if not isinstance(d, dict):
239
+ return d
240
+ keys = list(d.keys())
241
+ if keys and all(isinstance(k, str) and k.isdigit() for k in keys):
242
+ max_idx = max(int(k) for k in keys)
243
+ lst = [None] * (max_idx + 1)
244
+ for k in keys:
245
+ idx = int(k)
246
+ lst[idx] = EasyDict._lists_from_dict(d[k])
247
+ return lst
248
+ return {k: EasyDict._lists_from_dict(v) for k, v in d.items()}
249
+
250
+ def is_empty(self):
251
+ return len(self) == 0
@@ -0,0 +1,76 @@
1
+ Metadata-Version: 2.4
2
+ Name: easydotdict
3
+ Version: 1.0.0
4
+ Summary: Effortless nested dictionary access — dot notation, safe missing keys, auto-vivification, and more
5
+ Author-email: draganoxfool <draganogaming1@gmail.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/draganoxfool/Easydotdict
8
+ Project-URL: Source, https://github.com/draganoxfool/Easydotdict
9
+ Classifier: Development Status :: 5 - Production/Stable
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.8
14
+ Classifier: Programming Language :: Python :: 3.9
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
20
+ Requires-Python: >=3.8
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Dynamic: license-file
24
+
25
+ # easydotdict
26
+
27
+ Make nested dictionaries effortless — dot-notation access, safe missing-key handling, auto-vivification, deep path operations, and pretty-printing. Pure Python, no dependencies.
28
+
29
+ ```python
30
+ from easydotdict import EasyDict
31
+
32
+ d = EasyDict({'user': {'profile': {'name': 'Alice'}}})
33
+ print(d.user.profile.name) # Alice
34
+ print(d['user'].profile.name) # same
35
+ print(d.user.email) # None (safe, no error)
36
+
37
+ d.config.database.host = 'localhost' # auto-creates path
38
+ d.put('server.port', 8080) # or use path string
39
+ print(d.dig('user.name')) # Alice (deep path getter)
40
+
41
+ flat = d.flatten() # {'user.profile.name': 'Alice', ...}
42
+ restored = EasyDict.unflatten(flat) # reverse
43
+
44
+ d.merge({'settings': {'debug': True}}) # deep merge
45
+ print(d) # indented JSON
46
+ ```
47
+
48
+ ## Features
49
+
50
+ - **Dot notation** — `d.user.profile.name` instead of `d['user']['profile']['name']`
51
+ - **Dual access** — dot and bracket notation work interchangeably
52
+ - **Safe access** — `d.missing` returns `None`, no `KeyError`/`AttributeError`
53
+ - **Auto-vivification** — `d.a.b.c = value` auto-creates intermediate structures
54
+ - **Deep path operations** — `dig`, `put`, `has` with dot-separated strings
55
+ - **Flatten / Unflatten** — recursive flatten and restore with `flatten()` and `unflatten()`
56
+ - **Deep merge** — `update()` and `merge()` merge recursively, preserving existing keys
57
+ - **Clone** — `clone()` returns a deep independent copy
58
+ - **Empty check** — `is_empty()` checks if the dict has no keys
59
+ - **Auto-conversion** — nested `dict`s and `list`s containing `dict`s are wrapped automatically
60
+ - **Pretty-print** — `print(d)` outputs indented JSON
61
+ - **`to_dict()`** — recursively converts back to plain `dict`s and `list`s
62
+ - **Pure Python** — standard library only, Python 3.8+
63
+
64
+ ## Install
65
+
66
+ ```bash
67
+ pip install easydotdict
68
+ ```
69
+
70
+ ## Documentation
71
+
72
+ See [docs.md](docs.md) for full API reference, edge cases, and examples.
73
+
74
+ ## License
75
+
76
+ MIT
@@ -0,0 +1,9 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ easydotdict/__init__.py
5
+ easydotdict/easydotdict.py
6
+ easydotdict.egg-info/PKG-INFO
7
+ easydotdict.egg-info/SOURCES.txt
8
+ easydotdict.egg-info/dependency_links.txt
9
+ easydotdict.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ easydotdict
@@ -0,0 +1,36 @@
1
+ [build-system]
2
+ requires = ["setuptools>=64"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "easydotdict"
7
+ version = "1.0.0"
8
+ description = "Effortless nested dictionary access — dot notation, safe missing keys, auto-vivification, and more"
9
+ readme = "README.md"
10
+ license = {text = "MIT"}
11
+ requires-python = ">=3.8"
12
+
13
+ authors = [
14
+ {name = "draganoxfool", email = "draganogaming1@gmail.com"},
15
+ ]
16
+
17
+ classifiers = [
18
+ "Development Status :: 5 - Production/Stable",
19
+ "Intended Audience :: Developers",
20
+ "License :: OSI Approved :: MIT License",
21
+ "Programming Language :: Python :: 3",
22
+ "Programming Language :: Python :: 3.8",
23
+ "Programming Language :: Python :: 3.9",
24
+ "Programming Language :: Python :: 3.10",
25
+ "Programming Language :: Python :: 3.11",
26
+ "Programming Language :: Python :: 3.12",
27
+ "Programming Language :: Python :: 3.13",
28
+ "Topic :: Software Development :: Libraries :: Python Modules",
29
+ ]
30
+
31
+ [project.urls]
32
+ Homepage = "https://github.com/draganoxfool/Easydotdict"
33
+ Source = "https://github.com/draganoxfool/Easydotdict"
34
+
35
+ [tool.setuptools.packages.find]
36
+ include = ["easydotdict*"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+