%global _empty_manifest_terminate_build 0 Name: python-mergedeep Version: 1.3.4 Release: 1 Summary: A deep merge function for 🐍. License: MIT License URL: https://github.com/clarketm/mergedeep Source0: https://mirrors.nju.edu.cn/pypi/web/packages/3a/41/580bb4006e3ed0361b8151a01d324fb03f420815446c7def45d02f74c270/mergedeep-1.3.4.tar.gz BuildArch: noarch %description # [mergedeep](https://mergedeep.readthedocs.io/en/latest/) [![PyPi release](https://img.shields.io/pypi/v/mergedeep.svg)](https://pypi.org/project/mergedeep/) [![PyPi versions](https://img.shields.io/pypi/pyversions/mergedeep.svg)](https://pypi.org/project/mergedeep/) [![Downloads](https://pepy.tech/badge/mergedeep)](https://pepy.tech/project/mergedeep) [![Conda Version](https://img.shields.io/conda/vn/conda-forge/mergedeep.svg)](https://anaconda.org/conda-forge/mergedeep) [![Conda Downloads](https://img.shields.io/conda/dn/conda-forge/mergedeep.svg)](https://anaconda.org/conda-forge/mergedeep) [![Documentation Status](https://readthedocs.org/projects/mergedeep/badge/?version=latest)](https://mergedeep.readthedocs.io/en/latest/?badge=latest) A deep merge function for 🐍. [Check out the mergedeep docs](https://mergedeep.readthedocs.io/en/latest/) ## Installation ```bash $ pip install mergedeep ``` ## Usage ```text merge(destination: MutableMapping, *sources: Mapping, strategy: Strategy = Strategy.REPLACE) -> MutableMapping ``` Deep merge without mutating the source dicts. ```python3 from mergedeep import merge a = {"keyA": 1} b = {"keyB": {"sub1": 10}} c = {"keyB": {"sub2": 20}} merged = merge({}, a, b, c) print(merged) # {"keyA": 1, "keyB": {"sub1": 10, "sub2": 20}} ``` Deep merge into an existing dict. ```python3 from mergedeep import merge a = {"keyA": 1} b = {"keyB": {"sub1": 10}} c = {"keyB": {"sub2": 20}} merge(a, b, c) print(a) # {"keyA": 1, "keyB": {"sub1": 10, "sub2": 20}} ``` ### Merge strategies: 1. Replace (*default*) > `Strategy.REPLACE` ```python3 # When `destination` and `source` keys are the same, replace the `destination` value with one from `source` (default). # Note: with multiple sources, the `last` (i.e. rightmost) source value will be what appears in the merged result. from mergedeep import merge, Strategy dst = {"key": [1, 2]} src = {"key": [3, 4]} merge(dst, src, strategy=Strategy.REPLACE) # same as: merge(dst, src) print(dst) # {"key": [3, 4]} ``` 2. Additive > `Strategy.ADDITIVE` ```python3 # When `destination` and `source` values are both the same additive collection type, extend `destination` by adding values from `source`. # Additive collection types include: `list`, `tuple`, `set`, and `Counter` # Note: if the values are not additive collections of the same type, then fallback to a `REPLACE` merge. from mergedeep import merge, Strategy dst = {"key": [1, 2], "count": Counter({"a": 1, "b": 1})} src = {"key": [3, 4], "count": Counter({"a": 1, "c": 1})} merge(dst, src, strategy=Strategy.ADDITIVE) print(dst) # {"key": [1, 2, 3, 4], "count": Counter({"a": 2, "b": 1, "c": 1})} ``` 3. Typesafe replace > `Strategy.TYPESAFE_REPLACE` or `Strategy.TYPESAFE` ```python3 # When `destination` and `source` values are of different types, raise `TypeError`. Otherwise, perform a `REPLACE` merge. from mergedeep import merge, Strategy dst = {"key": [1, 2]} src = {"key": {3, 4}} merge(dst, src, strategy=Strategy.TYPESAFE_REPLACE) # same as: `Strategy.TYPESAFE` # TypeError: destination type: differs from source type: for key: "key" ``` 4. Typesafe additive > `Strategy.TYPESAFE_ADDITIVE` ```python3 # When `destination` and `source` values are of different types, raise `TypeError`. Otherwise, perform a `ADDITIVE` merge. from mergedeep import merge, Strategy dst = {"key": [1, 2]} src = {"key": {3, 4}} merge(dst, src, strategy=Strategy.TYPESAFE_ADDITIVE) # TypeError: destination type: differs from source type: for key: "key" ``` ## License MIT © [**Travis Clarke**](https://blog.travismclarke.com/) %package -n python3-mergedeep Summary: A deep merge function for 🐍. Provides: python-mergedeep BuildRequires: python3-devel BuildRequires: python3-setuptools BuildRequires: python3-pip %description -n python3-mergedeep # [mergedeep](https://mergedeep.readthedocs.io/en/latest/) [![PyPi release](https://img.shields.io/pypi/v/mergedeep.svg)](https://pypi.org/project/mergedeep/) [![PyPi versions](https://img.shields.io/pypi/pyversions/mergedeep.svg)](https://pypi.org/project/mergedeep/) [![Downloads](https://pepy.tech/badge/mergedeep)](https://pepy.tech/project/mergedeep) [![Conda Version](https://img.shields.io/conda/vn/conda-forge/mergedeep.svg)](https://anaconda.org/conda-forge/mergedeep) [![Conda Downloads](https://img.shields.io/conda/dn/conda-forge/mergedeep.svg)](https://anaconda.org/conda-forge/mergedeep) [![Documentation Status](https://readthedocs.org/projects/mergedeep/badge/?version=latest)](https://mergedeep.readthedocs.io/en/latest/?badge=latest) A deep merge function for 🐍. [Check out the mergedeep docs](https://mergedeep.readthedocs.io/en/latest/) ## Installation ```bash $ pip install mergedeep ``` ## Usage ```text merge(destination: MutableMapping, *sources: Mapping, strategy: Strategy = Strategy.REPLACE) -> MutableMapping ``` Deep merge without mutating the source dicts. ```python3 from mergedeep import merge a = {"keyA": 1} b = {"keyB": {"sub1": 10}} c = {"keyB": {"sub2": 20}} merged = merge({}, a, b, c) print(merged) # {"keyA": 1, "keyB": {"sub1": 10, "sub2": 20}} ``` Deep merge into an existing dict. ```python3 from mergedeep import merge a = {"keyA": 1} b = {"keyB": {"sub1": 10}} c = {"keyB": {"sub2": 20}} merge(a, b, c) print(a) # {"keyA": 1, "keyB": {"sub1": 10, "sub2": 20}} ``` ### Merge strategies: 1. Replace (*default*) > `Strategy.REPLACE` ```python3 # When `destination` and `source` keys are the same, replace the `destination` value with one from `source` (default). # Note: with multiple sources, the `last` (i.e. rightmost) source value will be what appears in the merged result. from mergedeep import merge, Strategy dst = {"key": [1, 2]} src = {"key": [3, 4]} merge(dst, src, strategy=Strategy.REPLACE) # same as: merge(dst, src) print(dst) # {"key": [3, 4]} ``` 2. Additive > `Strategy.ADDITIVE` ```python3 # When `destination` and `source` values are both the same additive collection type, extend `destination` by adding values from `source`. # Additive collection types include: `list`, `tuple`, `set`, and `Counter` # Note: if the values are not additive collections of the same type, then fallback to a `REPLACE` merge. from mergedeep import merge, Strategy dst = {"key": [1, 2], "count": Counter({"a": 1, "b": 1})} src = {"key": [3, 4], "count": Counter({"a": 1, "c": 1})} merge(dst, src, strategy=Strategy.ADDITIVE) print(dst) # {"key": [1, 2, 3, 4], "count": Counter({"a": 2, "b": 1, "c": 1})} ``` 3. Typesafe replace > `Strategy.TYPESAFE_REPLACE` or `Strategy.TYPESAFE` ```python3 # When `destination` and `source` values are of different types, raise `TypeError`. Otherwise, perform a `REPLACE` merge. from mergedeep import merge, Strategy dst = {"key": [1, 2]} src = {"key": {3, 4}} merge(dst, src, strategy=Strategy.TYPESAFE_REPLACE) # same as: `Strategy.TYPESAFE` # TypeError: destination type: differs from source type: for key: "key" ``` 4. Typesafe additive > `Strategy.TYPESAFE_ADDITIVE` ```python3 # When `destination` and `source` values are of different types, raise `TypeError`. Otherwise, perform a `ADDITIVE` merge. from mergedeep import merge, Strategy dst = {"key": [1, 2]} src = {"key": {3, 4}} merge(dst, src, strategy=Strategy.TYPESAFE_ADDITIVE) # TypeError: destination type: differs from source type: for key: "key" ``` ## License MIT © [**Travis Clarke**](https://blog.travismclarke.com/) %package help Summary: Development documents and examples for mergedeep Provides: python3-mergedeep-doc %description help # [mergedeep](https://mergedeep.readthedocs.io/en/latest/) [![PyPi release](https://img.shields.io/pypi/v/mergedeep.svg)](https://pypi.org/project/mergedeep/) [![PyPi versions](https://img.shields.io/pypi/pyversions/mergedeep.svg)](https://pypi.org/project/mergedeep/) [![Downloads](https://pepy.tech/badge/mergedeep)](https://pepy.tech/project/mergedeep) [![Conda Version](https://img.shields.io/conda/vn/conda-forge/mergedeep.svg)](https://anaconda.org/conda-forge/mergedeep) [![Conda Downloads](https://img.shields.io/conda/dn/conda-forge/mergedeep.svg)](https://anaconda.org/conda-forge/mergedeep) [![Documentation Status](https://readthedocs.org/projects/mergedeep/badge/?version=latest)](https://mergedeep.readthedocs.io/en/latest/?badge=latest) A deep merge function for 🐍. [Check out the mergedeep docs](https://mergedeep.readthedocs.io/en/latest/) ## Installation ```bash $ pip install mergedeep ``` ## Usage ```text merge(destination: MutableMapping, *sources: Mapping, strategy: Strategy = Strategy.REPLACE) -> MutableMapping ``` Deep merge without mutating the source dicts. ```python3 from mergedeep import merge a = {"keyA": 1} b = {"keyB": {"sub1": 10}} c = {"keyB": {"sub2": 20}} merged = merge({}, a, b, c) print(merged) # {"keyA": 1, "keyB": {"sub1": 10, "sub2": 20}} ``` Deep merge into an existing dict. ```python3 from mergedeep import merge a = {"keyA": 1} b = {"keyB": {"sub1": 10}} c = {"keyB": {"sub2": 20}} merge(a, b, c) print(a) # {"keyA": 1, "keyB": {"sub1": 10, "sub2": 20}} ``` ### Merge strategies: 1. Replace (*default*) > `Strategy.REPLACE` ```python3 # When `destination` and `source` keys are the same, replace the `destination` value with one from `source` (default). # Note: with multiple sources, the `last` (i.e. rightmost) source value will be what appears in the merged result. from mergedeep import merge, Strategy dst = {"key": [1, 2]} src = {"key": [3, 4]} merge(dst, src, strategy=Strategy.REPLACE) # same as: merge(dst, src) print(dst) # {"key": [3, 4]} ``` 2. Additive > `Strategy.ADDITIVE` ```python3 # When `destination` and `source` values are both the same additive collection type, extend `destination` by adding values from `source`. # Additive collection types include: `list`, `tuple`, `set`, and `Counter` # Note: if the values are not additive collections of the same type, then fallback to a `REPLACE` merge. from mergedeep import merge, Strategy dst = {"key": [1, 2], "count": Counter({"a": 1, "b": 1})} src = {"key": [3, 4], "count": Counter({"a": 1, "c": 1})} merge(dst, src, strategy=Strategy.ADDITIVE) print(dst) # {"key": [1, 2, 3, 4], "count": Counter({"a": 2, "b": 1, "c": 1})} ``` 3. Typesafe replace > `Strategy.TYPESAFE_REPLACE` or `Strategy.TYPESAFE` ```python3 # When `destination` and `source` values are of different types, raise `TypeError`. Otherwise, perform a `REPLACE` merge. from mergedeep import merge, Strategy dst = {"key": [1, 2]} src = {"key": {3, 4}} merge(dst, src, strategy=Strategy.TYPESAFE_REPLACE) # same as: `Strategy.TYPESAFE` # TypeError: destination type: differs from source type: for key: "key" ``` 4. Typesafe additive > `Strategy.TYPESAFE_ADDITIVE` ```python3 # When `destination` and `source` values are of different types, raise `TypeError`. Otherwise, perform a `ADDITIVE` merge. from mergedeep import merge, Strategy dst = {"key": [1, 2]} src = {"key": {3, 4}} merge(dst, src, strategy=Strategy.TYPESAFE_ADDITIVE) # TypeError: destination type: differs from source type: for key: "key" ``` ## License MIT © [**Travis Clarke**](https://blog.travismclarke.com/) %prep %autosetup -n mergedeep-1.3.4 %build %py3_build %install %py3_install install -d -m755 %{buildroot}/%{_pkgdocdir} if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi pushd %{buildroot} if [ -d usr/lib ]; then find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/lib64 ]; then find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/bin ]; then find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/sbin ]; then find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst fi touch doclist.lst if [ -d usr/share/man ]; then find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst fi popd mv %{buildroot}/filelist.lst . mv %{buildroot}/doclist.lst . %files -n python3-mergedeep -f filelist.lst %dir %{python3_sitelib}/* %files help -f doclist.lst %{_docdir}/* %changelog * Fri Apr 21 2023 Python_Bot - 1.3.4-1 - Package Spec generated