python-benedict 0.29.1__tar.gz → 0.30.1__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.
- {python-benedict-0.29.1/python_benedict.egg-info → python-benedict-0.30.1}/PKG-INFO +126 -87
- {python-benedict-0.29.1 → python-benedict-0.30.1}/README.md +98 -78
- {python-benedict-0.29.1 → python-benedict-0.30.1}/benedict/dicts/__init__.py +3 -0
- {python-benedict-0.29.1 → python-benedict-0.30.1}/benedict/dicts/io/io_dict.py +7 -3
- {python-benedict-0.29.1 → python-benedict-0.30.1}/benedict/dicts/io/io_util.py +1 -1
- {python-benedict-0.29.1 → python-benedict-0.30.1}/benedict/dicts/keyattr/keyattr_dict.py +19 -7
- {python-benedict-0.29.1 → python-benedict-0.30.1}/benedict/metadata.py +1 -1
- {python-benedict-0.29.1 → python-benedict-0.30.1}/benedict/serializers/csv.py +1 -1
- {python-benedict-0.29.1 → python-benedict-0.30.1}/benedict/serializers/ini.py +26 -7
- {python-benedict-0.29.1 → python-benedict-0.30.1}/benedict/serializers/xls.py +6 -6
- python-benedict-0.30.1/pyproject.toml +176 -0
- {python-benedict-0.29.1 → python-benedict-0.30.1/python_benedict.egg-info}/PKG-INFO +126 -87
- {python-benedict-0.29.1 → python-benedict-0.30.1}/python_benedict.egg-info/SOURCES.txt +0 -1
- {python-benedict-0.29.1 → python-benedict-0.30.1}/python_benedict.egg-info/requires.txt +1 -1
- python-benedict-0.30.1/setup.cfg +4 -0
- python-benedict-0.29.1/pyproject.toml +0 -21
- python-benedict-0.29.1/setup.cfg +0 -141
- {python-benedict-0.29.1 → python-benedict-0.30.1}/LICENSE.txt +0 -0
- {python-benedict-0.29.1 → python-benedict-0.30.1}/MANIFEST.in +0 -0
- {python-benedict-0.29.1 → python-benedict-0.30.1}/benedict/__init__.py +0 -0
- {python-benedict-0.29.1 → python-benedict-0.30.1}/benedict/core/__init__.py +0 -0
- {python-benedict-0.29.1 → python-benedict-0.30.1}/benedict/core/clean.py +0 -0
- {python-benedict-0.29.1 → python-benedict-0.30.1}/benedict/core/clone.py +0 -0
- {python-benedict-0.29.1 → python-benedict-0.30.1}/benedict/core/dump.py +0 -0
- {python-benedict-0.29.1 → python-benedict-0.30.1}/benedict/core/filter.py +0 -0
- {python-benedict-0.29.1 → python-benedict-0.30.1}/benedict/core/find.py +0 -0
- {python-benedict-0.29.1 → python-benedict-0.30.1}/benedict/core/flatten.py +0 -0
- {python-benedict-0.29.1 → python-benedict-0.30.1}/benedict/core/groupby.py +0 -0
- {python-benedict-0.29.1 → python-benedict-0.30.1}/benedict/core/invert.py +0 -0
- {python-benedict-0.29.1 → python-benedict-0.30.1}/benedict/core/items_sorted.py +0 -0
- {python-benedict-0.29.1 → python-benedict-0.30.1}/benedict/core/keylists.py +0 -0
- {python-benedict-0.29.1 → python-benedict-0.30.1}/benedict/core/keypaths.py +0 -0
- {python-benedict-0.29.1 → python-benedict-0.30.1}/benedict/core/match.py +0 -0
- {python-benedict-0.29.1 → python-benedict-0.30.1}/benedict/core/merge.py +0 -0
- {python-benedict-0.29.1 → python-benedict-0.30.1}/benedict/core/move.py +0 -0
- {python-benedict-0.29.1 → python-benedict-0.30.1}/benedict/core/nest.py +0 -0
- {python-benedict-0.29.1 → python-benedict-0.30.1}/benedict/core/remove.py +0 -0
- {python-benedict-0.29.1 → python-benedict-0.30.1}/benedict/core/rename.py +0 -0
- {python-benedict-0.29.1 → python-benedict-0.30.1}/benedict/core/search.py +0 -0
- {python-benedict-0.29.1 → python-benedict-0.30.1}/benedict/core/standardize.py +0 -0
- {python-benedict-0.29.1 → python-benedict-0.30.1}/benedict/core/subset.py +0 -0
- {python-benedict-0.29.1 → python-benedict-0.30.1}/benedict/core/swap.py +0 -0
- {python-benedict-0.29.1 → python-benedict-0.30.1}/benedict/core/traverse.py +0 -0
- {python-benedict-0.29.1 → python-benedict-0.30.1}/benedict/core/unflatten.py +0 -0
- {python-benedict-0.29.1 → python-benedict-0.30.1}/benedict/core/unique.py +0 -0
- {python-benedict-0.29.1 → python-benedict-0.30.1}/benedict/dicts/base/__init__.py +0 -0
- {python-benedict-0.29.1 → python-benedict-0.30.1}/benedict/dicts/base/base_dict.py +0 -0
- {python-benedict-0.29.1 → python-benedict-0.30.1}/benedict/dicts/io/__init__.py +0 -0
- {python-benedict-0.29.1 → python-benedict-0.30.1}/benedict/dicts/keyattr/__init__.py +0 -0
- {python-benedict-0.29.1 → python-benedict-0.30.1}/benedict/dicts/keylist/__init__.py +0 -0
- {python-benedict-0.29.1 → python-benedict-0.30.1}/benedict/dicts/keylist/keylist_dict.py +0 -0
- {python-benedict-0.29.1 → python-benedict-0.30.1}/benedict/dicts/keylist/keylist_util.py +0 -0
- {python-benedict-0.29.1 → python-benedict-0.30.1}/benedict/dicts/keypath/__init__.py +0 -0
- {python-benedict-0.29.1 → python-benedict-0.30.1}/benedict/dicts/keypath/keypath_dict.py +0 -0
- {python-benedict-0.29.1 → python-benedict-0.30.1}/benedict/dicts/keypath/keypath_util.py +0 -0
- {python-benedict-0.29.1 → python-benedict-0.30.1}/benedict/dicts/parse/__init__.py +0 -0
- {python-benedict-0.29.1 → python-benedict-0.30.1}/benedict/dicts/parse/parse_dict.py +0 -0
- {python-benedict-0.29.1 → python-benedict-0.30.1}/benedict/dicts/parse/parse_util.py +0 -0
- {python-benedict-0.29.1 → python-benedict-0.30.1}/benedict/exceptions.py +0 -0
- {python-benedict-0.29.1 → python-benedict-0.30.1}/benedict/extras.py +0 -0
- {python-benedict-0.29.1 → python-benedict-0.30.1}/benedict/serializers/__init__.py +0 -0
- {python-benedict-0.29.1 → python-benedict-0.30.1}/benedict/serializers/abstract.py +0 -0
- {python-benedict-0.29.1 → python-benedict-0.30.1}/benedict/serializers/base64.py +0 -0
- {python-benedict-0.29.1 → python-benedict-0.30.1}/benedict/serializers/json.py +0 -0
- {python-benedict-0.29.1 → python-benedict-0.30.1}/benedict/serializers/pickle.py +0 -0
- {python-benedict-0.29.1 → python-benedict-0.30.1}/benedict/serializers/plist.py +0 -0
- {python-benedict-0.29.1 → python-benedict-0.30.1}/benedict/serializers/query_string.py +0 -0
- {python-benedict-0.29.1 → python-benedict-0.30.1}/benedict/serializers/toml.py +0 -0
- {python-benedict-0.29.1 → python-benedict-0.30.1}/benedict/serializers/xml.py +0 -0
- {python-benedict-0.29.1 → python-benedict-0.30.1}/benedict/serializers/yaml.py +0 -0
- {python-benedict-0.29.1 → python-benedict-0.30.1}/benedict/utils/__init__.py +0 -0
- {python-benedict-0.29.1 → python-benedict-0.30.1}/benedict/utils/type_util.py +0 -0
- {python-benedict-0.29.1 → python-benedict-0.30.1}/python_benedict.egg-info/dependency_links.txt +0 -0
- {python-benedict-0.29.1 → python-benedict-0.30.1}/python_benedict.egg-info/top_level.txt +0 -0
- {python-benedict-0.29.1 → python-benedict-0.30.1}/setup.py +0 -0
|
@@ -1,14 +1,33 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: python-benedict
|
|
3
|
-
Version: 0.
|
|
4
|
-
Summary: python-benedict is a dict subclass with keylist/keypath support, normalized I/O operations (base64, csv, ini, json, pickle, plist, query-string, toml, xls, xml, yaml) and many utilities... for humans, obviously.
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
Version: 0.30.1
|
|
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
|
+
Author-email: Fabio Caccamo <fabio.caccamo@gmail.com>
|
|
6
|
+
Maintainer-email: Fabio Caccamo <fabio.caccamo@gmail.com>
|
|
7
|
+
License: MIT License
|
|
8
|
+
|
|
9
|
+
Copyright (c) 2019-present Fabio Caccamo
|
|
10
|
+
|
|
11
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
12
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
13
|
+
in the Software without restriction, including without limitation the rights
|
|
14
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
15
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
16
|
+
furnished to do so, subject to the following conditions:
|
|
17
|
+
|
|
18
|
+
The above copyright notice and this permission notice shall be included in all
|
|
19
|
+
copies or substantial portions of the Software.
|
|
20
|
+
|
|
21
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
22
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
23
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
24
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
25
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
26
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
27
|
+
SOFTWARE.
|
|
28
|
+
|
|
29
|
+
Project-URL: Homepage, https://github.com/fabiocaccamo/python-benedict
|
|
30
|
+
Project-URL: Download, https://github.com/fabiocaccamo/python-benedict/releases
|
|
12
31
|
Project-URL: Documentation, https://github.com/fabiocaccamo/python-benedict#readme
|
|
13
32
|
Project-URL: Issues, https://github.com/fabiocaccamo/python-benedict/issues
|
|
14
33
|
Project-URL: Funding, https://github.com/sponsors/fabiocaccamo/
|
|
@@ -63,7 +82,7 @@ License-File: LICENSE.txt
|
|
|
63
82
|
|
|
64
83
|
|
|
65
84
|
# python-benedict
|
|
66
|
-
python-benedict is a dict subclass with **keylist/keypath** support, **I/O** shortcuts (`base64`, `csv`, `ini`, `json`, `pickle`, `plist`, `query-string`, `toml`, `xls`, `xml`, `yaml`) and many **utilities**... for humans, obviously.
|
|
85
|
+
python-benedict is a dict subclass with **keylist/keypath/keyattr** support, **I/O** shortcuts (`base64`, `csv`, `ini`, `json`, `pickle`, `plist`, `query-string`, `toml`, `xls`, `xml`, `yaml`) and many **utilities**... for humans, obviously.
|
|
67
86
|
|
|
68
87
|
## Features
|
|
69
88
|
- 100% **backward-compatible**, you can safely wrap existing dictionaries.
|
|
@@ -81,9 +100,9 @@ python-benedict is a dict subclass with **keylist/keypath** support, **I/O** sho
|
|
|
81
100
|
- [Optional Requirements](#optional-requirements)
|
|
82
101
|
- [Usage](#usage)
|
|
83
102
|
- [Basics](#basics)
|
|
84
|
-
- [Keyattr](#keyattr)
|
|
85
|
-
- [Keylist](#keylist)
|
|
86
|
-
- [Keypath](#keypath)
|
|
103
|
+
- [Keyattr](#keyattr) `my_dict.x.y.z`
|
|
104
|
+
- [Keylist](#keylist) `my_dict["x", "y", "z"]`
|
|
105
|
+
- [Keypath](#keypath) `my_dict["x.y.z"]`
|
|
87
106
|
- [Custom keypath separator](#custom-keypath-separator)
|
|
88
107
|
- [Change keypath separator](#change-keypath-separator)
|
|
89
108
|
- [Disable keypath functionality](#disable-keypath-functionality)
|
|
@@ -139,25 +158,42 @@ page = params.get_int("page", 1)
|
|
|
139
158
|
It is possible to get/set items using **keys as attributes** (dotted notation).
|
|
140
159
|
|
|
141
160
|
```python
|
|
142
|
-
d = benedict()
|
|
161
|
+
d = benedict(keyattr_dynamic=True) # default False
|
|
143
162
|
d.profile.firstname = "Fabio"
|
|
144
163
|
d.profile.lastname = "Caccamo"
|
|
145
164
|
print(d) # -> { "profile":{ "firstname":"Fabio", "lastname":"Caccamo" } }
|
|
146
165
|
```
|
|
147
166
|
|
|
167
|
+
By default, if the `keyattr_dynamic` is not explicitly set to `True`, this functionality works for get/set only already existing items.
|
|
168
|
+
|
|
148
169
|
#### Disable keyattr functionality
|
|
149
|
-
You can disable the keyattr functionality passing `keyattr_enabled=False` in the constructor.
|
|
170
|
+
You can disable the keyattr functionality passing `keyattr_enabled=False` option in the constructor.
|
|
150
171
|
|
|
151
172
|
```python
|
|
152
|
-
d = benedict(existing_dict, keyattr_enabled=False)
|
|
173
|
+
d = benedict(existing_dict, keyattr_enabled=False) # default True
|
|
153
174
|
```
|
|
154
175
|
|
|
155
|
-
|
|
176
|
+
or using the `getter/setter` property.
|
|
156
177
|
|
|
157
178
|
```python
|
|
158
179
|
d.keyattr_enabled = False
|
|
159
180
|
```
|
|
160
181
|
|
|
182
|
+
#### Dynamic keyattr functionality
|
|
183
|
+
You can enable the dynamic attributes access functionality passing `keyattr_dynamic=True` in the constructor.
|
|
184
|
+
|
|
185
|
+
```python
|
|
186
|
+
d = benedict(existing_dict, keyattr_dynamic=True) # default False
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
or using the `getter/setter` property.
|
|
190
|
+
|
|
191
|
+
```python
|
|
192
|
+
d.keyattr_dynamic = True
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
> **Warning** - even if this feature is very useful, it has some obvious limitations: it works only for string keys that are *unprotected* (not starting with an `_`) and that don't clash with the currently supported methods names.
|
|
196
|
+
|
|
161
197
|
### Keylist
|
|
162
198
|
Wherever a **key** is used, it is possible to use also a **list (or a tuple) of keys**.
|
|
163
199
|
|
|
@@ -220,13 +256,13 @@ d.keypath_separator = "/"
|
|
|
220
256
|
```
|
|
221
257
|
|
|
222
258
|
#### Disable keypath functionality
|
|
223
|
-
You can disable the keypath functionality passing `keypath_separator=None` in the constructor.
|
|
259
|
+
You can disable the keypath functionality passing `keypath_separator=None` option in the constructor.
|
|
224
260
|
|
|
225
261
|
```python
|
|
226
262
|
d = benedict(existing_dict, keypath_separator=None)
|
|
227
263
|
```
|
|
228
264
|
|
|
229
|
-
|
|
265
|
+
or using the `getter/setter` property.
|
|
230
266
|
|
|
231
267
|
```python
|
|
232
268
|
d.keypath_separator = None
|
|
@@ -329,7 +365,7 @@ Utilities that accept key argument(s) also support keypath(s).
|
|
|
329
365
|
|
|
330
366
|
Utilities that return a dictionary always return a new `benedict` instance.
|
|
331
367
|
|
|
332
|
-
|
|
368
|
+
#### `clean`
|
|
333
369
|
|
|
334
370
|
```python
|
|
335
371
|
# Clean the current dict instance removing all empty values: None, "", {}, [], ().
|
|
@@ -338,14 +374,14 @@ Utilities that return a dictionary always return a new `benedict` instance.
|
|
|
338
374
|
d.clean(strings=True, collections=True)
|
|
339
375
|
```
|
|
340
376
|
|
|
341
|
-
|
|
377
|
+
#### `clone`
|
|
342
378
|
|
|
343
379
|
```python
|
|
344
380
|
# Return a clone (deepcopy) of the dict.
|
|
345
381
|
c = d.clone()
|
|
346
382
|
```
|
|
347
383
|
|
|
348
|
-
|
|
384
|
+
#### `dump`
|
|
349
385
|
|
|
350
386
|
```python
|
|
351
387
|
# Return a readable representation of any dict/list.
|
|
@@ -357,7 +393,7 @@ d = benedict()
|
|
|
357
393
|
print(d.dump())
|
|
358
394
|
```
|
|
359
395
|
|
|
360
|
-
|
|
396
|
+
#### `filter`
|
|
361
397
|
|
|
362
398
|
```python
|
|
363
399
|
# Return a filtered dict using the given predicate function.
|
|
@@ -366,7 +402,7 @@ predicate = lambda k, v: v is not None
|
|
|
366
402
|
f = d.filter(predicate)
|
|
367
403
|
```
|
|
368
404
|
|
|
369
|
-
|
|
405
|
+
#### `find`
|
|
370
406
|
|
|
371
407
|
```python
|
|
372
408
|
# Return the first match searching for the given keys/keypaths.
|
|
@@ -375,21 +411,21 @@ keys = ["a.b.c", "m.n.o", "x.y.z"]
|
|
|
375
411
|
f = d.find(keys, default=0)
|
|
376
412
|
```
|
|
377
413
|
|
|
378
|
-
|
|
414
|
+
#### `flatten`
|
|
379
415
|
|
|
380
416
|
```python
|
|
381
417
|
# Return a new flattened dict using the given separator to join nested dict keys to flatten keypaths.
|
|
382
418
|
f = d.flatten(separator="_")
|
|
383
419
|
```
|
|
384
420
|
|
|
385
|
-
|
|
421
|
+
#### `groupby`
|
|
386
422
|
|
|
387
423
|
```python
|
|
388
424
|
# Group a list of dicts at key by the value of the given by_key and return a new dict.
|
|
389
425
|
g = d.groupby("cities", by_key="country_code")
|
|
390
426
|
```
|
|
391
427
|
|
|
392
|
-
|
|
428
|
+
#### `invert`
|
|
393
429
|
|
|
394
430
|
```python
|
|
395
431
|
# Return an inverted dict where values become keys and keys become values.
|
|
@@ -398,7 +434,7 @@ g = d.groupby("cities", by_key="country_code")
|
|
|
398
434
|
i = d.invert(flat=False)
|
|
399
435
|
```
|
|
400
436
|
|
|
401
|
-
|
|
437
|
+
#### `items_sorted_by_keys`
|
|
402
438
|
|
|
403
439
|
```python
|
|
404
440
|
# Return items (key/value list) sorted by keys.
|
|
@@ -406,7 +442,7 @@ i = d.invert(flat=False)
|
|
|
406
442
|
items = d.items_sorted_by_keys(reverse=False)
|
|
407
443
|
```
|
|
408
444
|
|
|
409
|
-
|
|
445
|
+
#### `items_sorted_by_values`
|
|
410
446
|
|
|
411
447
|
```python
|
|
412
448
|
# Return items (key/value list) sorted by values.
|
|
@@ -414,7 +450,7 @@ items = d.items_sorted_by_keys(reverse=False)
|
|
|
414
450
|
items = d.items_sorted_by_values(reverse=False)
|
|
415
451
|
```
|
|
416
452
|
|
|
417
|
-
|
|
453
|
+
#### `keypaths`
|
|
418
454
|
|
|
419
455
|
```python
|
|
420
456
|
# Return a list of all keypaths in the dict.
|
|
@@ -422,7 +458,7 @@ items = d.items_sorted_by_values(reverse=False)
|
|
|
422
458
|
k = d.keypaths(indexes=False)
|
|
423
459
|
```
|
|
424
460
|
|
|
425
|
-
|
|
461
|
+
#### `match`
|
|
426
462
|
|
|
427
463
|
```python
|
|
428
464
|
# Return a list of all values whose keypath matches the given pattern (a regex or string).
|
|
@@ -431,7 +467,7 @@ k = d.keypaths(indexes=False)
|
|
|
431
467
|
m = d.match(pattern, indexes=True)
|
|
432
468
|
```
|
|
433
469
|
|
|
434
|
-
|
|
470
|
+
#### `merge`
|
|
435
471
|
|
|
436
472
|
```python
|
|
437
473
|
# Merge one or more dictionary objects into current instance (deepupdate).
|
|
@@ -441,7 +477,7 @@ m = d.match(pattern, indexes=True)
|
|
|
441
477
|
d.merge(a, b, c, overwrite=True, concat=False)
|
|
442
478
|
```
|
|
443
479
|
|
|
444
|
-
|
|
480
|
+
#### `move`
|
|
445
481
|
|
|
446
482
|
```python
|
|
447
483
|
# Move an item from key_src to key_dst.
|
|
@@ -450,7 +486,7 @@ d.merge(a, b, c, overwrite=True, concat=False)
|
|
|
450
486
|
d.move("a", "b", overwrite=True)
|
|
451
487
|
```
|
|
452
488
|
|
|
453
|
-
|
|
489
|
+
#### `nest`
|
|
454
490
|
|
|
455
491
|
```python
|
|
456
492
|
# Nest a list of dicts at the given key and return a new nested list
|
|
@@ -458,7 +494,7 @@ d.move("a", "b", overwrite=True)
|
|
|
458
494
|
d.nest("values", id_key="id", parent_id_key="parent_id", children_key="children")
|
|
459
495
|
```
|
|
460
496
|
|
|
461
|
-
|
|
497
|
+
#### `remove`
|
|
462
498
|
|
|
463
499
|
```python
|
|
464
500
|
# Remove multiple keys from the dict.
|
|
@@ -466,7 +502,7 @@ d.nest("values", id_key="id", parent_id_key="parent_id", children_key="children"
|
|
|
466
502
|
d.remove(["firstname", "lastname", "email"])
|
|
467
503
|
```
|
|
468
504
|
|
|
469
|
-
|
|
505
|
+
#### `rename`
|
|
470
506
|
|
|
471
507
|
```python
|
|
472
508
|
# Rename a dict item key from "key" to "key_new".
|
|
@@ -474,21 +510,21 @@ d.remove(["firstname", "lastname", "email"])
|
|
|
474
510
|
d.rename("first_name", "firstname")
|
|
475
511
|
```
|
|
476
512
|
|
|
477
|
-
|
|
513
|
+
#### `search`
|
|
478
514
|
|
|
479
515
|
```python
|
|
480
516
|
# Search and return a list of items (dict, key, value, ) matching the given query.
|
|
481
517
|
r = d.search("hello", in_keys=True, in_values=True, exact=False, case_sensitive=False)
|
|
482
518
|
```
|
|
483
519
|
|
|
484
|
-
|
|
520
|
+
#### `standardize`
|
|
485
521
|
|
|
486
522
|
```python
|
|
487
523
|
# Standardize all dict keys, e.g. "Location Latitude" -> "location_latitude".
|
|
488
524
|
d.standardize()
|
|
489
525
|
```
|
|
490
526
|
|
|
491
|
-
|
|
527
|
+
#### `subset`
|
|
492
528
|
|
|
493
529
|
```python
|
|
494
530
|
# Return a dict subset for the given keys.
|
|
@@ -496,14 +532,14 @@ d.standardize()
|
|
|
496
532
|
s = d.subset(["firstname", "lastname", "email"])
|
|
497
533
|
```
|
|
498
534
|
|
|
499
|
-
|
|
535
|
+
#### `swap`
|
|
500
536
|
|
|
501
537
|
```python
|
|
502
538
|
# Swap items values at the given keys.
|
|
503
539
|
d.swap("firstname", "lastname")
|
|
504
540
|
```
|
|
505
541
|
|
|
506
|
-
|
|
542
|
+
#### `traverse`
|
|
507
543
|
|
|
508
544
|
```python
|
|
509
545
|
# Traverse a dict passing each item (dict, key, value) to the given callback function.
|
|
@@ -512,14 +548,14 @@ def f(d, key, value):
|
|
|
512
548
|
d.traverse(f)
|
|
513
549
|
```
|
|
514
550
|
|
|
515
|
-
|
|
551
|
+
#### `unflatten`
|
|
516
552
|
|
|
517
553
|
```python
|
|
518
554
|
# Return a new unflattened dict using the given separator to split dict keys to nested keypaths.
|
|
519
555
|
u = d.unflatten(separator="_")
|
|
520
556
|
```
|
|
521
557
|
|
|
522
|
-
|
|
558
|
+
#### `unique`
|
|
523
559
|
|
|
524
560
|
```python
|
|
525
561
|
# Remove duplicated values from the dict.
|
|
@@ -550,7 +586,7 @@ In all `from_*` methods, the first argument can be: **url**, **filepath** or **d
|
|
|
550
586
|
|
|
551
587
|
In all `to_*` methods, if `filepath="..."` kwarg is specified, the output will be also **saved** at the specified filepath.
|
|
552
588
|
|
|
553
|
-
|
|
589
|
+
#### `from_base64`
|
|
554
590
|
|
|
555
591
|
```python
|
|
556
592
|
# Try to load/decode a base64 encoded data and return it as benedict instance.
|
|
@@ -562,7 +598,7 @@ In all `to_*` methods, if `filepath="..."` kwarg is specified, the output will b
|
|
|
562
598
|
d = benedict.from_base64(s, subformat="json", encoding="utf-8", **kwargs)
|
|
563
599
|
```
|
|
564
600
|
|
|
565
|
-
|
|
601
|
+
#### `from_csv`
|
|
566
602
|
|
|
567
603
|
```python
|
|
568
604
|
# Try to load/decode a csv encoded data and return it as benedict instance.
|
|
@@ -574,7 +610,7 @@ d = benedict.from_base64(s, subformat="json", encoding="utf-8", **kwargs)
|
|
|
574
610
|
d = benedict.from_csv(s, columns=None, columns_row=True, **kwargs)
|
|
575
611
|
```
|
|
576
612
|
|
|
577
|
-
|
|
613
|
+
#### `from_ini`
|
|
578
614
|
|
|
579
615
|
```python
|
|
580
616
|
# Try to load/decode a ini encoded data and return it as benedict instance.
|
|
@@ -585,7 +621,7 @@ d = benedict.from_csv(s, columns=None, columns_row=True, **kwargs)
|
|
|
585
621
|
d = benedict.from_ini(s, **kwargs)
|
|
586
622
|
```
|
|
587
623
|
|
|
588
|
-
|
|
624
|
+
#### `from_json`
|
|
589
625
|
|
|
590
626
|
```python
|
|
591
627
|
# Try to load/decode a json encoded data and return it as benedict instance.
|
|
@@ -596,7 +632,7 @@ d = benedict.from_ini(s, **kwargs)
|
|
|
596
632
|
d = benedict.from_json(s, **kwargs)
|
|
597
633
|
```
|
|
598
634
|
|
|
599
|
-
|
|
635
|
+
#### `from_pickle`
|
|
600
636
|
|
|
601
637
|
```python
|
|
602
638
|
# Try to load/decode a pickle encoded in Base64 format and return it as benedict instance.
|
|
@@ -607,7 +643,7 @@ d = benedict.from_json(s, **kwargs)
|
|
|
607
643
|
d = benedict.from_pickle(s, **kwargs)
|
|
608
644
|
```
|
|
609
645
|
|
|
610
|
-
|
|
646
|
+
#### `from_plist`
|
|
611
647
|
|
|
612
648
|
```python
|
|
613
649
|
# Try to load/decode a p-list encoded data and return it as benedict instance.
|
|
@@ -618,7 +654,7 @@ d = benedict.from_pickle(s, **kwargs)
|
|
|
618
654
|
d = benedict.from_plist(s, **kwargs)
|
|
619
655
|
```
|
|
620
656
|
|
|
621
|
-
|
|
657
|
+
#### `from_query_string`
|
|
622
658
|
|
|
623
659
|
```python
|
|
624
660
|
# Try to load/decode a query-string and return it as benedict instance.
|
|
@@ -627,7 +663,7 @@ d = benedict.from_plist(s, **kwargs)
|
|
|
627
663
|
d = benedict.from_query_string(s, **kwargs)
|
|
628
664
|
```
|
|
629
665
|
|
|
630
|
-
|
|
666
|
+
#### `from_toml`
|
|
631
667
|
|
|
632
668
|
```python
|
|
633
669
|
# Try to load/decode a toml encoded data and return it as benedict instance.
|
|
@@ -638,7 +674,7 @@ d = benedict.from_query_string(s, **kwargs)
|
|
|
638
674
|
d = benedict.from_toml(s, **kwargs)
|
|
639
675
|
```
|
|
640
676
|
|
|
641
|
-
|
|
677
|
+
#### `from_xls`
|
|
642
678
|
|
|
643
679
|
```python
|
|
644
680
|
# Try to load/decode a xls file (".xls", ".xlsx", ".xlsm") from url, filepath or data-string.
|
|
@@ -650,7 +686,7 @@ d = benedict.from_toml(s, **kwargs)
|
|
|
650
686
|
d = benedict.from_xls(s, sheet=0, columns=None, columns_row=True, **kwargs)
|
|
651
687
|
```
|
|
652
688
|
|
|
653
|
-
|
|
689
|
+
#### `from_xml`
|
|
654
690
|
|
|
655
691
|
```python
|
|
656
692
|
# Try to load/decode a xml encoded data and return it as benedict instance.
|
|
@@ -661,7 +697,7 @@ d = benedict.from_xls(s, sheet=0, columns=None, columns_row=True, **kwargs)
|
|
|
661
697
|
d = benedict.from_xml(s, **kwargs)
|
|
662
698
|
```
|
|
663
699
|
|
|
664
|
-
|
|
700
|
+
#### `from_yaml`
|
|
665
701
|
|
|
666
702
|
```python
|
|
667
703
|
# Try to load/decode a yaml encoded data and return it as benedict instance.
|
|
@@ -672,7 +708,7 @@ d = benedict.from_xml(s, **kwargs)
|
|
|
672
708
|
d = benedict.from_yaml(s, **kwargs)
|
|
673
709
|
```
|
|
674
710
|
|
|
675
|
-
|
|
711
|
+
#### `to_base64`
|
|
676
712
|
|
|
677
713
|
```python
|
|
678
714
|
# Return the dict instance encoded in base64 format and optionally save it at the specified 'filepath'.
|
|
@@ -684,7 +720,7 @@ d = benedict.from_yaml(s, **kwargs)
|
|
|
684
720
|
s = d.to_base64(subformat="json", encoding="utf-8", **kwargs)
|
|
685
721
|
```
|
|
686
722
|
|
|
687
|
-
|
|
723
|
+
#### `to_csv`
|
|
688
724
|
|
|
689
725
|
```python
|
|
690
726
|
# Return a list of dicts in the current dict encoded in csv format and optionally save it at the specified filepath.
|
|
@@ -694,7 +730,7 @@ s = d.to_base64(subformat="json", encoding="utf-8", **kwargs)
|
|
|
694
730
|
s = d.to_csv(key="values", columns=None, columns_row=True, **kwargs)
|
|
695
731
|
```
|
|
696
732
|
|
|
697
|
-
|
|
733
|
+
#### `to_ini`
|
|
698
734
|
|
|
699
735
|
```python
|
|
700
736
|
# Return the dict instance encoded in ini format and optionally save it at the specified filepath.
|
|
@@ -704,7 +740,7 @@ s = d.to_csv(key="values", columns=None, columns_row=True, **kwargs)
|
|
|
704
740
|
s = d.to_ini(**kwargs)
|
|
705
741
|
```
|
|
706
742
|
|
|
707
|
-
|
|
743
|
+
#### `to_json`
|
|
708
744
|
|
|
709
745
|
```python
|
|
710
746
|
# Return the dict instance encoded in json format and optionally save it at the specified filepath.
|
|
@@ -714,7 +750,7 @@ s = d.to_ini(**kwargs)
|
|
|
714
750
|
s = d.to_json(**kwargs)
|
|
715
751
|
```
|
|
716
752
|
|
|
717
|
-
|
|
753
|
+
#### `to_pickle`
|
|
718
754
|
|
|
719
755
|
```python
|
|
720
756
|
# Return the dict instance as pickle encoded in Base64 format and optionally save it at the specified filepath.
|
|
@@ -725,7 +761,7 @@ s = d.to_json(**kwargs)
|
|
|
725
761
|
s = d.to_pickle(**kwargs)
|
|
726
762
|
```
|
|
727
763
|
|
|
728
|
-
|
|
764
|
+
#### `to_plist`
|
|
729
765
|
|
|
730
766
|
```python
|
|
731
767
|
# Return the dict instance encoded in p-list format and optionally save it at the specified filepath.
|
|
@@ -735,7 +771,7 @@ s = d.to_pickle(**kwargs)
|
|
|
735
771
|
s = d.to_plist(**kwargs)
|
|
736
772
|
```
|
|
737
773
|
|
|
738
|
-
|
|
774
|
+
#### `to_query_string`
|
|
739
775
|
|
|
740
776
|
```python
|
|
741
777
|
# Return the dict instance as query-string and optionally save it at the specified filepath.
|
|
@@ -743,7 +779,7 @@ s = d.to_plist(**kwargs)
|
|
|
743
779
|
s = d.to_query_string(**kwargs)
|
|
744
780
|
```
|
|
745
781
|
|
|
746
|
-
|
|
782
|
+
#### `to_toml`
|
|
747
783
|
|
|
748
784
|
```python
|
|
749
785
|
# Return the dict instance encoded in toml format and optionally save it at the specified filepath.
|
|
@@ -753,7 +789,7 @@ s = d.to_query_string(**kwargs)
|
|
|
753
789
|
s = d.to_toml(**kwargs)
|
|
754
790
|
```
|
|
755
791
|
|
|
756
|
-
|
|
792
|
+
#### `to_xml`
|
|
757
793
|
|
|
758
794
|
```python
|
|
759
795
|
# Return the dict instance encoded in xml format and optionally save it at the specified filepath.
|
|
@@ -763,7 +799,7 @@ s = d.to_toml(**kwargs)
|
|
|
763
799
|
s = d.to_xml(**kwargs)
|
|
764
800
|
```
|
|
765
801
|
|
|
766
|
-
|
|
802
|
+
#### `to_yaml`
|
|
767
803
|
|
|
768
804
|
```python
|
|
769
805
|
# Return the dict instance encoded in yaml format.
|
|
@@ -778,7 +814,7 @@ s = d.to_yaml(**kwargs)
|
|
|
778
814
|
|
|
779
815
|
These methods are wrappers of the `get` method, they parse data trying to return it in the expected type.
|
|
780
816
|
|
|
781
|
-
|
|
817
|
+
#### `get_bool`
|
|
782
818
|
|
|
783
819
|
```python
|
|
784
820
|
# Get value by key or keypath trying to return it as bool.
|
|
@@ -786,7 +822,7 @@ These methods are wrappers of the `get` method, they parse data trying to return
|
|
|
786
822
|
d.get_bool(key, default=False)
|
|
787
823
|
```
|
|
788
824
|
|
|
789
|
-
|
|
825
|
+
#### `get_bool_list`
|
|
790
826
|
|
|
791
827
|
```python
|
|
792
828
|
# Get value by key or keypath trying to return it as list of bool values.
|
|
@@ -794,7 +830,7 @@ d.get_bool(key, default=False)
|
|
|
794
830
|
d.get_bool_list(key, default=[], separator=",")
|
|
795
831
|
```
|
|
796
832
|
|
|
797
|
-
|
|
833
|
+
#### `get_date`
|
|
798
834
|
|
|
799
835
|
```python
|
|
800
836
|
# Get value by key or keypath trying to return it as date.
|
|
@@ -803,7 +839,7 @@ d.get_bool_list(key, default=[], separator=",")
|
|
|
803
839
|
d.get_date(key, default=None, format=None, choices=[])
|
|
804
840
|
```
|
|
805
841
|
|
|
806
|
-
|
|
842
|
+
#### `get_date_list`
|
|
807
843
|
|
|
808
844
|
```python
|
|
809
845
|
# Get value by key or keypath trying to return it as list of date values.
|
|
@@ -811,7 +847,7 @@ d.get_date(key, default=None, format=None, choices=[])
|
|
|
811
847
|
d.get_date_list(key, default=[], format=None, separator=",")
|
|
812
848
|
```
|
|
813
849
|
|
|
814
|
-
|
|
850
|
+
#### `get_datetime`
|
|
815
851
|
|
|
816
852
|
```python
|
|
817
853
|
# Get value by key or keypath trying to return it as datetime.
|
|
@@ -820,7 +856,7 @@ d.get_date_list(key, default=[], format=None, separator=",")
|
|
|
820
856
|
d.get_datetime(key, default=None, format=None, choices=[])
|
|
821
857
|
```
|
|
822
858
|
|
|
823
|
-
|
|
859
|
+
#### `get_datetime_list`
|
|
824
860
|
|
|
825
861
|
```python
|
|
826
862
|
# Get value by key or keypath trying to return it as list of datetime values.
|
|
@@ -828,7 +864,7 @@ d.get_datetime(key, default=None, format=None, choices=[])
|
|
|
828
864
|
d.get_datetime_list(key, default=[], format=None, separator=",")
|
|
829
865
|
```
|
|
830
866
|
|
|
831
|
-
|
|
867
|
+
#### `get_decimal`
|
|
832
868
|
|
|
833
869
|
```python
|
|
834
870
|
# Get value by key or keypath trying to return it as Decimal.
|
|
@@ -836,7 +872,7 @@ d.get_datetime_list(key, default=[], format=None, separator=",")
|
|
|
836
872
|
d.get_decimal(key, default=Decimal("0.0"), choices=[])
|
|
837
873
|
```
|
|
838
874
|
|
|
839
|
-
|
|
875
|
+
#### `get_decimal_list`
|
|
840
876
|
|
|
841
877
|
```python
|
|
842
878
|
# Get value by key or keypath trying to return it as list of Decimal values.
|
|
@@ -844,7 +880,7 @@ d.get_decimal(key, default=Decimal("0.0"), choices=[])
|
|
|
844
880
|
d.get_decimal_list(key, default=[], separator=",")
|
|
845
881
|
```
|
|
846
882
|
|
|
847
|
-
|
|
883
|
+
#### `get_dict`
|
|
848
884
|
|
|
849
885
|
```python
|
|
850
886
|
# Get value by key or keypath trying to return it as dict.
|
|
@@ -852,7 +888,7 @@ d.get_decimal_list(key, default=[], separator=",")
|
|
|
852
888
|
d.get_dict(key, default={})
|
|
853
889
|
```
|
|
854
890
|
|
|
855
|
-
|
|
891
|
+
#### `get_email`
|
|
856
892
|
|
|
857
893
|
```python
|
|
858
894
|
# Get email by key or keypath and return it.
|
|
@@ -861,7 +897,7 @@ d.get_dict(key, default={})
|
|
|
861
897
|
d.get_email(key, default="", choices=None, check_blacklist=True)
|
|
862
898
|
```
|
|
863
899
|
|
|
864
|
-
|
|
900
|
+
#### `get_float`
|
|
865
901
|
|
|
866
902
|
```python
|
|
867
903
|
# Get value by key or keypath trying to return it as float.
|
|
@@ -869,7 +905,7 @@ d.get_email(key, default="", choices=None, check_blacklist=True)
|
|
|
869
905
|
d.get_float(key, default=0.0, choices=[])
|
|
870
906
|
```
|
|
871
907
|
|
|
872
|
-
|
|
908
|
+
#### `get_float_list`
|
|
873
909
|
|
|
874
910
|
```python
|
|
875
911
|
# Get value by key or keypath trying to return it as list of float values.
|
|
@@ -877,7 +913,7 @@ d.get_float(key, default=0.0, choices=[])
|
|
|
877
913
|
d.get_float_list(key, default=[], separator=",")
|
|
878
914
|
```
|
|
879
915
|
|
|
880
|
-
|
|
916
|
+
#### `get_int`
|
|
881
917
|
|
|
882
918
|
```python
|
|
883
919
|
# Get value by key or keypath trying to return it as int.
|
|
@@ -885,7 +921,7 @@ d.get_float_list(key, default=[], separator=",")
|
|
|
885
921
|
d.get_int(key, default=0, choices=[])
|
|
886
922
|
```
|
|
887
923
|
|
|
888
|
-
|
|
924
|
+
#### `get_int_list`
|
|
889
925
|
|
|
890
926
|
```python
|
|
891
927
|
# Get value by key or keypath trying to return it as list of int values.
|
|
@@ -893,7 +929,7 @@ d.get_int(key, default=0, choices=[])
|
|
|
893
929
|
d.get_int_list(key, default=[], separator=",")
|
|
894
930
|
```
|
|
895
931
|
|
|
896
|
-
|
|
932
|
+
#### `get_list`
|
|
897
933
|
|
|
898
934
|
```python
|
|
899
935
|
# Get value by key or keypath trying to return it as list.
|
|
@@ -901,7 +937,7 @@ d.get_int_list(key, default=[], separator=",")
|
|
|
901
937
|
d.get_list(key, default=[], separator=",")
|
|
902
938
|
```
|
|
903
939
|
|
|
904
|
-
|
|
940
|
+
#### `get_list_item`
|
|
905
941
|
|
|
906
942
|
```python
|
|
907
943
|
# Get list by key or keypath and return value at the specified index.
|
|
@@ -909,7 +945,7 @@ d.get_list(key, default=[], separator=",")
|
|
|
909
945
|
d.get_list_item(key, index=0, default=None, separator=",")
|
|
910
946
|
```
|
|
911
947
|
|
|
912
|
-
|
|
948
|
+
#### `get_phonenumber`
|
|
913
949
|
|
|
914
950
|
```python
|
|
915
951
|
# Get phone number by key or keypath and return a dict with different formats (e164, international, national).
|
|
@@ -917,7 +953,7 @@ d.get_list_item(key, index=0, default=None, separator=",")
|
|
|
917
953
|
d.get_phonenumber(key, country_code=None, default=None)
|
|
918
954
|
```
|
|
919
955
|
|
|
920
|
-
|
|
956
|
+
#### `get_slug`
|
|
921
957
|
|
|
922
958
|
```python
|
|
923
959
|
# Get value by key or keypath trying to return it as slug.
|
|
@@ -925,7 +961,7 @@ d.get_phonenumber(key, country_code=None, default=None)
|
|
|
925
961
|
d.get_slug(key, default="", choices=[])
|
|
926
962
|
```
|
|
927
963
|
|
|
928
|
-
|
|
964
|
+
#### `get_slug_list`
|
|
929
965
|
|
|
930
966
|
```python
|
|
931
967
|
# Get value by key or keypath trying to return it as list of slug values.
|
|
@@ -933,7 +969,7 @@ d.get_slug(key, default="", choices=[])
|
|
|
933
969
|
d.get_slug_list(key, default=[], separator=",")
|
|
934
970
|
```
|
|
935
971
|
|
|
936
|
-
|
|
972
|
+
#### `get_str`
|
|
937
973
|
|
|
938
974
|
```python
|
|
939
975
|
# Get value by key or keypath trying to return it as string.
|
|
@@ -942,7 +978,7 @@ d.get_slug_list(key, default=[], separator=",")
|
|
|
942
978
|
d.get_str(key, default="", choices=[])
|
|
943
979
|
```
|
|
944
980
|
|
|
945
|
-
|
|
981
|
+
#### `get_str_list`
|
|
946
982
|
|
|
947
983
|
```python
|
|
948
984
|
# Get value by key or keypath trying to return it as list of str values.
|
|
@@ -950,7 +986,7 @@ d.get_str(key, default="", choices=[])
|
|
|
950
986
|
d.get_str_list(key, default=[], separator=",")
|
|
951
987
|
```
|
|
952
988
|
|
|
953
|
-
|
|
989
|
+
#### `get_uuid`
|
|
954
990
|
|
|
955
991
|
```python
|
|
956
992
|
# Get value by key or keypath trying to return it as valid uuid.
|
|
@@ -958,7 +994,7 @@ d.get_str_list(key, default=[], separator=",")
|
|
|
958
994
|
d.get_uuid(key, default="", choices=[])
|
|
959
995
|
```
|
|
960
996
|
|
|
961
|
-
|
|
997
|
+
#### `get_uuid_list`
|
|
962
998
|
|
|
963
999
|
```python
|
|
964
1000
|
# Get value by key or keypath trying to return it as list of valid uuid values.
|
|
@@ -980,6 +1016,9 @@ python -m pip install --upgrade pip
|
|
|
980
1016
|
# install requirements
|
|
981
1017
|
pip install -r requirements.txt -r requirements-test.txt
|
|
982
1018
|
|
|
1019
|
+
# install pre-commit to run formatters and linters
|
|
1020
|
+
pre-commit install --install-hooks
|
|
1021
|
+
|
|
983
1022
|
# run tests using tox
|
|
984
1023
|
tox
|
|
985
1024
|
|