Bigt is a Python library for compare or merge nested unsorted dictionaries.
Project description
bigt
Bigt is a Python library for compare or merge nested unsorted dictionaries.
Examples:
from bigt.dictext import DictExt
a = {"a": {"a": "str", "b": 123}}
b = {"a": {"a": "str", "b": 1234}}
result, not_present, changed = DictExt(b).issubset(a)
assert not result
assert changed == {"a": {"b": {"old": 1234, "new": 123} } }
assert not not_present
>>> DictExt({"a": 3, "b": [{"b": 123}]}) + DictExt({"a": 1, "c": False, "b": [{"a": 12.64}]})
{'a': 1, 'b': [{'b': 123, 'a': 12.64}], 'c': False}
>>> DictExt({"aa": 3, "a": [{"b": {"bv": 1, "bc": 2}, "a": 1}, [3,1,8,5]]}).sort()
{'a': [[1, 3, 5, 8], {'a': 1, 'b': {'bc': 2, 'bv': 1}}], 'aa': 3}
Show difference visually
Install rich python library or use pip install Bigt[rich]
from bigt.pprint import pprint
a = {"a":[{'z': {'a': '21', 'b': False, 'd': '20'}}, {'z': {'a': '1', 'b': False, 'd': '2'}}]}
b = {"a":[{'z': {'a': '1', 'b': False, 'd': {"a": '20'}, "y": {"a": 2}}}]}
pprint(b, a, weights={"a": {'z': {"a": 2}}})
from bigt.pprint import pprint
a = {"a":[{'z': {'a': '21', 'b': False, 'd': '20'}}, {'z': {'a': '1', 'b': False, 'd': '2'}}]}
b = {"a":[{'z': {'a': '1', 'b': False, 'd': {"a": '20'}, "y": {"a": 2}}}]}
pprint(a, b, weights={"a": {'z': {"a": 2}}})
Assert on difference found
from bigt.pprint import assert_issubset
a = {"a":[{'z': {'a': '21', 'b': False, 'd': '20'}}, {'z': {'a': '1', 'b': False, 'd': '2'}}]}
b = {"a":[{'z': {'a': '1', 'b': False, 'd': {"a": '20'}, "y": {"a": 2}}}]}
assert_issubset(a, b, weights={"a": {'z': {"a": 2}}})
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
Bigt-2022.1.4-py3-none-any.whl
(11.0 kB
view details)
File details
Details for the file Bigt-2022.1.4-py3-none-any.whl.
File metadata
- Download URL: Bigt-2022.1.4-py3-none-any.whl
- Upload date:
- Size: 11.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d45ab6a50cdb98d622972a73cdf2701bf4a92cd8d2b0e3edd0d52dc2babd25c
|
|
| MD5 |
7078c82ffacd605ff163a71a3c55171f
|
|
| BLAKE2b-256 |
08c4ea96e9442da07878f3904c949dc56723203b4afe458490cb8ff947f3619e
|