summaryrefslogtreecommitdiff
path: root/python-nested-diff.spec
diff options
context:
space:
mode:
authorCoprDistGit <infra@openeuler.org>2023-05-05 04:38:52 +0000
committerCoprDistGit <infra@openeuler.org>2023-05-05 04:38:52 +0000
commit5d7b687ffc87c500223dbfb212dbd1959e2e9223 (patch)
tree090d695706dd9afd972a299e65ec51c20170eed1 /python-nested-diff.spec
parent30a796122f19b614bc0e76c6cbb514791b5fecce (diff)
automatic import of python-nested-diffopeneuler20.03
Diffstat (limited to 'python-nested-diff.spec')
-rw-r--r--python-nested-diff.spec509
1 files changed, 509 insertions, 0 deletions
diff --git a/python-nested-diff.spec b/python-nested-diff.spec
new file mode 100644
index 0000000..e3bcc19
--- /dev/null
+++ b/python-nested-diff.spec
@@ -0,0 +1,509 @@
+%global _empty_manifest_terminate_build 0
+Name: python-nested-diff
+Version: 1.1
+Release: 1
+Summary: Recursive diff for nested structures
+License: Apache License 2.0
+URL: https://github.com/mr-mixas/Nested-Diff.py
+Source0: https://mirrors.nju.edu.cn/pypi/web/packages/08/88/62ec634eb4217c9420105dd5de0ddf16fa53a9acce74e2f08628fa2384c6/nested_diff-1.1.tar.gz
+BuildArch: noarch
+
+Requires: python3-pyyaml
+Requires: python3-toml
+
+%description
+# Nested-Diff.py
+
+Recursive diff and patch for nested structures. **[Live Demo](https://nesteddiff.pythonanywhere.com/)**
+
+[![Tests Status](https://github.com/mr-mixas/Nested-Diff.py/actions/workflows/tests.yml/badge.svg)](https://github.com/mr-mixas/Nested-Diff.py/actions?query=branch%3Amaster)
+[![Coverage Status](https://coveralls.io/repos/github/mr-mixas/Nested-Diff.py/badge.svg)](https://coveralls.io/github/mr-mixas/Nested-Diff.py)
+[![Supported Python versions](https://img.shields.io/pypi/pyversions/nested_diff.svg)](https://pypi.org/project/nested_diff/)
+[![License](https://img.shields.io/pypi/l/nested_diff.svg)](https://pypi.org/project/nested_diff/)
+
+## Install
+
+`pip install nested_diff`
+
+For extra formats support (YAML, TOML) in cli tools, use
+
+`pip install nested_diff[cli]`
+
+## Command line tools
+
+```
+mixas:~/$ cat a.json b.json
+[0, [1], 3]
+[0, [1, 2], 3]
+mixas:~/$ nested_diff a.json b.json
+ [1]
++ [1]
++ 2
+mixas:~/$
+mixas:~/$ nested_diff a.json b.json --ofmt json > patch.json
+mixas:~/$ nested_patch a.json patch.json
+```
+
+## Library usage
+
+```
+>>> from nested_diff import diff, patch
+>>>
+>>> a = {'one': 1, 'two': 2, 'three': 3}
+>>> b = {'one': 1, 'two': 42}
+>>>
+>>> diff(a, b)
+{'D': {'three': {'R': 3}, 'two': {'N': 42, 'O': 2}, 'one': {'U': 1}}}
+>>>
+>>> diff(a, b, O=False, U=False)
+{'D': {'three': {'R': 3}, 'two': {'N': 42}}}
+>>>
+>>>
+>>> c = [0,1,2,3]
+>>> d = [ 1,2,4,5]
+>>>
+>>> c = patch(c, diff(c, d))
+>>> assert c == d
+>>>
+```
+
+### Formatting diffs
+
+```
+>>> from nested_diff import diff
+>>> from nested_diff.formatters import TextFormatter
+>>>
+>>> a = {'one': 1, 'two': 'some\ntext\ninside'}
+>>> b = {'one': 0, 'two': 'some\ntext'}
+>>>
+>>> d = diff(a, b, U=False, text_diff_ctx=3)
+>>> print(TextFormatter().format(d))
+ {'one'}
+- 1
++ 0
+ {'two'}
+# <str>
+ @@ -1,3 +1,2 @@
+ some
+ text
+- inside
+<BLANKLINE>
+>>>
+```
+
+See more examples in [HOWTO](./HOWTO.md) and [tests](./tests/).
+
+## Diff structure
+
+Diff is a dict and may contain status keys:
+
+* `A` stands for 'added', it's value - added item.
+* `D` means 'different' and contains subdiff.
+* `N` is a new value for changed item.
+* `O` is a changed item's old value.
+* `R` key used for removed item.
+* `U` represent unchanged item.
+
+and auxiliary keys:
+
+* `C` comment; optional, value - arbitrary string.
+* `E` extension ID (optional).
+* `I` index for sequence item, used only when prior item was omitted.
+
+Diff metadata alternates with actual data; simple types specified as is, dicts,
+lists and tuples contain subdiffs for their items with native for such types
+addressing: indexes for lists and tuples, keys for dictionaries. Any status
+key, except `D` may be omitted during diff computation. `E` key is used with
+`D` when entity unable to contain diff by itself (set, frozenset for example);
+`D` contain a list of subdiffs in this case.
+
+### Annotated example:
+
+```
+a: {"one": [5,7]}
+b: {"one": [5], "two": 2}
+opts: U=False # omit unchanged items
+
+diff:
+{"D": {"one": {"D": [{"I": 1, "R": 7}]}, "two": {"A": 2}}}
+| | | | | | || | | | | | | | |
+| | | | | | || | | | | | | | +- with value 2
+| | | | | | || | | | | | | +- key 'two' was added
+| | | | | | || | | | | | +- subdiff for it
+| | | | | | || | | | | +- another key from top-level
+| | | | | | || | | | +- what it was (item's value: 7)
+| | | | | | || | | +- what happened to item (removed)
+| | | | | | || | +- list item's actual index
+| | | | | | || +- prior item was omitted
+| | | | | | |+- subdiff for list item
+| | | | | | +- it's value - list
+| | | | | +- it is deeply changed
+| | | | +- subdiff for key 'one'
+| | | +- it has key 'one'
+| | +- top-level thing is a dict
+| +- changes somewhere deeply inside
++- diff is always a dict
+```
+
+## License
+
+Licensed under the terms of the [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0).
+
+## See Also
+
+[HOWTO](./HOWTO.md)
+
+[deepdiff](https://pypi.org/project/deepdiff/),
+[jsondiff](https://pypi.org/project/jsondiff/),
+[jsonpatch](https://pypi.org/project/jsonpatch/),
+[json-delta](https://pypi.org/project/json-delta/)
+
+
+%package -n python3-nested-diff
+Summary: Recursive diff for nested structures
+Provides: python-nested-diff
+BuildRequires: python3-devel
+BuildRequires: python3-setuptools
+BuildRequires: python3-pip
+%description -n python3-nested-diff
+# Nested-Diff.py
+
+Recursive diff and patch for nested structures. **[Live Demo](https://nesteddiff.pythonanywhere.com/)**
+
+[![Tests Status](https://github.com/mr-mixas/Nested-Diff.py/actions/workflows/tests.yml/badge.svg)](https://github.com/mr-mixas/Nested-Diff.py/actions?query=branch%3Amaster)
+[![Coverage Status](https://coveralls.io/repos/github/mr-mixas/Nested-Diff.py/badge.svg)](https://coveralls.io/github/mr-mixas/Nested-Diff.py)
+[![Supported Python versions](https://img.shields.io/pypi/pyversions/nested_diff.svg)](https://pypi.org/project/nested_diff/)
+[![License](https://img.shields.io/pypi/l/nested_diff.svg)](https://pypi.org/project/nested_diff/)
+
+## Install
+
+`pip install nested_diff`
+
+For extra formats support (YAML, TOML) in cli tools, use
+
+`pip install nested_diff[cli]`
+
+## Command line tools
+
+```
+mixas:~/$ cat a.json b.json
+[0, [1], 3]
+[0, [1, 2], 3]
+mixas:~/$ nested_diff a.json b.json
+ [1]
++ [1]
++ 2
+mixas:~/$
+mixas:~/$ nested_diff a.json b.json --ofmt json > patch.json
+mixas:~/$ nested_patch a.json patch.json
+```
+
+## Library usage
+
+```
+>>> from nested_diff import diff, patch
+>>>
+>>> a = {'one': 1, 'two': 2, 'three': 3}
+>>> b = {'one': 1, 'two': 42}
+>>>
+>>> diff(a, b)
+{'D': {'three': {'R': 3}, 'two': {'N': 42, 'O': 2}, 'one': {'U': 1}}}
+>>>
+>>> diff(a, b, O=False, U=False)
+{'D': {'three': {'R': 3}, 'two': {'N': 42}}}
+>>>
+>>>
+>>> c = [0,1,2,3]
+>>> d = [ 1,2,4,5]
+>>>
+>>> c = patch(c, diff(c, d))
+>>> assert c == d
+>>>
+```
+
+### Formatting diffs
+
+```
+>>> from nested_diff import diff
+>>> from nested_diff.formatters import TextFormatter
+>>>
+>>> a = {'one': 1, 'two': 'some\ntext\ninside'}
+>>> b = {'one': 0, 'two': 'some\ntext'}
+>>>
+>>> d = diff(a, b, U=False, text_diff_ctx=3)
+>>> print(TextFormatter().format(d))
+ {'one'}
+- 1
++ 0
+ {'two'}
+# <str>
+ @@ -1,3 +1,2 @@
+ some
+ text
+- inside
+<BLANKLINE>
+>>>
+```
+
+See more examples in [HOWTO](./HOWTO.md) and [tests](./tests/).
+
+## Diff structure
+
+Diff is a dict and may contain status keys:
+
+* `A` stands for 'added', it's value - added item.
+* `D` means 'different' and contains subdiff.
+* `N` is a new value for changed item.
+* `O` is a changed item's old value.
+* `R` key used for removed item.
+* `U` represent unchanged item.
+
+and auxiliary keys:
+
+* `C` comment; optional, value - arbitrary string.
+* `E` extension ID (optional).
+* `I` index for sequence item, used only when prior item was omitted.
+
+Diff metadata alternates with actual data; simple types specified as is, dicts,
+lists and tuples contain subdiffs for their items with native for such types
+addressing: indexes for lists and tuples, keys for dictionaries. Any status
+key, except `D` may be omitted during diff computation. `E` key is used with
+`D` when entity unable to contain diff by itself (set, frozenset for example);
+`D` contain a list of subdiffs in this case.
+
+### Annotated example:
+
+```
+a: {"one": [5,7]}
+b: {"one": [5], "two": 2}
+opts: U=False # omit unchanged items
+
+diff:
+{"D": {"one": {"D": [{"I": 1, "R": 7}]}, "two": {"A": 2}}}
+| | | | | | || | | | | | | | |
+| | | | | | || | | | | | | | +- with value 2
+| | | | | | || | | | | | | +- key 'two' was added
+| | | | | | || | | | | | +- subdiff for it
+| | | | | | || | | | | +- another key from top-level
+| | | | | | || | | | +- what it was (item's value: 7)
+| | | | | | || | | +- what happened to item (removed)
+| | | | | | || | +- list item's actual index
+| | | | | | || +- prior item was omitted
+| | | | | | |+- subdiff for list item
+| | | | | | +- it's value - list
+| | | | | +- it is deeply changed
+| | | | +- subdiff for key 'one'
+| | | +- it has key 'one'
+| | +- top-level thing is a dict
+| +- changes somewhere deeply inside
++- diff is always a dict
+```
+
+## License
+
+Licensed under the terms of the [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0).
+
+## See Also
+
+[HOWTO](./HOWTO.md)
+
+[deepdiff](https://pypi.org/project/deepdiff/),
+[jsondiff](https://pypi.org/project/jsondiff/),
+[jsonpatch](https://pypi.org/project/jsonpatch/),
+[json-delta](https://pypi.org/project/json-delta/)
+
+
+%package help
+Summary: Development documents and examples for nested-diff
+Provides: python3-nested-diff-doc
+%description help
+# Nested-Diff.py
+
+Recursive diff and patch for nested structures. **[Live Demo](https://nesteddiff.pythonanywhere.com/)**
+
+[![Tests Status](https://github.com/mr-mixas/Nested-Diff.py/actions/workflows/tests.yml/badge.svg)](https://github.com/mr-mixas/Nested-Diff.py/actions?query=branch%3Amaster)
+[![Coverage Status](https://coveralls.io/repos/github/mr-mixas/Nested-Diff.py/badge.svg)](https://coveralls.io/github/mr-mixas/Nested-Diff.py)
+[![Supported Python versions](https://img.shields.io/pypi/pyversions/nested_diff.svg)](https://pypi.org/project/nested_diff/)
+[![License](https://img.shields.io/pypi/l/nested_diff.svg)](https://pypi.org/project/nested_diff/)
+
+## Install
+
+`pip install nested_diff`
+
+For extra formats support (YAML, TOML) in cli tools, use
+
+`pip install nested_diff[cli]`
+
+## Command line tools
+
+```
+mixas:~/$ cat a.json b.json
+[0, [1], 3]
+[0, [1, 2], 3]
+mixas:~/$ nested_diff a.json b.json
+ [1]
++ [1]
++ 2
+mixas:~/$
+mixas:~/$ nested_diff a.json b.json --ofmt json > patch.json
+mixas:~/$ nested_patch a.json patch.json
+```
+
+## Library usage
+
+```
+>>> from nested_diff import diff, patch
+>>>
+>>> a = {'one': 1, 'two': 2, 'three': 3}
+>>> b = {'one': 1, 'two': 42}
+>>>
+>>> diff(a, b)
+{'D': {'three': {'R': 3}, 'two': {'N': 42, 'O': 2}, 'one': {'U': 1}}}
+>>>
+>>> diff(a, b, O=False, U=False)
+{'D': {'three': {'R': 3}, 'two': {'N': 42}}}
+>>>
+>>>
+>>> c = [0,1,2,3]
+>>> d = [ 1,2,4,5]
+>>>
+>>> c = patch(c, diff(c, d))
+>>> assert c == d
+>>>
+```
+
+### Formatting diffs
+
+```
+>>> from nested_diff import diff
+>>> from nested_diff.formatters import TextFormatter
+>>>
+>>> a = {'one': 1, 'two': 'some\ntext\ninside'}
+>>> b = {'one': 0, 'two': 'some\ntext'}
+>>>
+>>> d = diff(a, b, U=False, text_diff_ctx=3)
+>>> print(TextFormatter().format(d))
+ {'one'}
+- 1
++ 0
+ {'two'}
+# <str>
+ @@ -1,3 +1,2 @@
+ some
+ text
+- inside
+<BLANKLINE>
+>>>
+```
+
+See more examples in [HOWTO](./HOWTO.md) and [tests](./tests/).
+
+## Diff structure
+
+Diff is a dict and may contain status keys:
+
+* `A` stands for 'added', it's value - added item.
+* `D` means 'different' and contains subdiff.
+* `N` is a new value for changed item.
+* `O` is a changed item's old value.
+* `R` key used for removed item.
+* `U` represent unchanged item.
+
+and auxiliary keys:
+
+* `C` comment; optional, value - arbitrary string.
+* `E` extension ID (optional).
+* `I` index for sequence item, used only when prior item was omitted.
+
+Diff metadata alternates with actual data; simple types specified as is, dicts,
+lists and tuples contain subdiffs for their items with native for such types
+addressing: indexes for lists and tuples, keys for dictionaries. Any status
+key, except `D` may be omitted during diff computation. `E` key is used with
+`D` when entity unable to contain diff by itself (set, frozenset for example);
+`D` contain a list of subdiffs in this case.
+
+### Annotated example:
+
+```
+a: {"one": [5,7]}
+b: {"one": [5], "two": 2}
+opts: U=False # omit unchanged items
+
+diff:
+{"D": {"one": {"D": [{"I": 1, "R": 7}]}, "two": {"A": 2}}}
+| | | | | | || | | | | | | | |
+| | | | | | || | | | | | | | +- with value 2
+| | | | | | || | | | | | | +- key 'two' was added
+| | | | | | || | | | | | +- subdiff for it
+| | | | | | || | | | | +- another key from top-level
+| | | | | | || | | | +- what it was (item's value: 7)
+| | | | | | || | | +- what happened to item (removed)
+| | | | | | || | +- list item's actual index
+| | | | | | || +- prior item was omitted
+| | | | | | |+- subdiff for list item
+| | | | | | +- it's value - list
+| | | | | +- it is deeply changed
+| | | | +- subdiff for key 'one'
+| | | +- it has key 'one'
+| | +- top-level thing is a dict
+| +- changes somewhere deeply inside
++- diff is always a dict
+```
+
+## License
+
+Licensed under the terms of the [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0).
+
+## See Also
+
+[HOWTO](./HOWTO.md)
+
+[deepdiff](https://pypi.org/project/deepdiff/),
+[jsondiff](https://pypi.org/project/jsondiff/),
+[jsonpatch](https://pypi.org/project/jsonpatch/),
+[json-delta](https://pypi.org/project/json-delta/)
+
+
+%prep
+%autosetup -n nested-diff-1.1
+
+%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-nested-diff -f filelist.lst
+%dir %{python3_sitelib}/*
+
+%files help -f doclist.lst
+%{_docdir}/*
+
+%changelog
+* Fri May 05 2023 Python_Bot <Python_Bot@openeuler.org> - 1.1-1
+- Package Spec generated