Add utilities for merging dictionaries and deduplicating lists of items.

Review Request #11217 — Created Oct. 13, 2020 and submitted — Latest diff uploaded

Information

Django Evolution
master

Reviewers

This introduces a couple of new datastructure-related utility functions
that will be used in some upcoming changes.

filter_dup_list_items() takes a list of items and filters out any
duplicates, ensuring that there is one of each instance in the list.
This is similar to passing a list into set(), but preserves the order.

merge_dicts() merges two dictionaries together. Its approach is
simplistic but sufficient for our needs. Keys present only in the source
dictionary are placed in the destination. Lists are concatenated.
Dictionaries are recursively merged. Anything else triggers an error.

Unit tests and doc generation were added for these new functions.

Unit tests pass.

Tested these in upcoming changes.

Diff Revision 1

This is not the most recent revision of the diff. The latest diff is revision 3. See what's changed.

orig
1
2
3

Commits

First Last Summary ID Author
Add utilities for merging dictionaries and deduplicating lists of items.
This introduces a couple of new datastructure-related utility functions that will be used in some upcoming changes. `filter_dup_list_items()` takes a list of items and filters out any duplicates, ensuring that there is one of each instance in the list. This is similar to passing a list into `set()`, but preserves the order. `merge_dicts()` merges two dictionaries together. Its approach is simplistic but sufficient for our needs. Keys present only in the source dictionary are placed in the destination. Lists are concatenated. Dictionaries are recursively merged. Anything else triggers an error. Unit tests and doc generation were added for these new functions.
f1ead5bb911c812e8a9d42a0ca5a4da35274aa9f Christian Hammond
django_evolution/tests/test_datastructures_utils.py
django_evolution/utils/datastructures.py
docs/coderef/index.rst
Loading...