summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCoprDistGit <infra@openeuler.org>2023-04-10 15:52:44 +0000
committerCoprDistGit <infra@openeuler.org>2023-04-10 15:52:44 +0000
commit502a4f866afbfa06492e99e52a4924cc6f8b79d5 (patch)
tree0f98f96baf2e59c48f0b9d4fa1096fb1488678e3
parent480727b4ecfa616f5d6b04e97f1d1bd9c2294831 (diff)
automatic import of python-jsonmerge
-rw-r--r--.gitignore1
-rw-r--r--python-jsonmerge.spec414
-rw-r--r--sources1
3 files changed, 416 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index e69de29..9e71b2d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -0,0 +1 @@
+/jsonmerge-1.9.0.tar.gz
diff --git a/python-jsonmerge.spec b/python-jsonmerge.spec
new file mode 100644
index 0000000..a379d7c
--- /dev/null
+++ b/python-jsonmerge.spec
@@ -0,0 +1,414 @@
+%global _empty_manifest_terminate_build 0
+Name: python-jsonmerge
+Version: 1.9.0
+Release: 1
+Summary: Merge a series of JSON documents.
+License: MIT
+URL: https://pypi.org/project/jsonmerge/
+Source0: https://mirrors.nju.edu.cn/pypi/web/packages/8b/81/7284c1871590f688b145af26611a3bd9daea9dbcb149492f2f46eb0c696f/jsonmerge-1.9.0.tar.gz
+BuildArch: noarch
+
+
+%description
+This Python module allows you to merge a series of JSON documents into a
+single one.
+This problem often occurs for example when different authors fill in
+different parts of a common document and you need to construct a document
+that includes contributions from all the authors. It also helps when
+dealing with consecutive versions of a document where different fields get
+updated over time.
+Consider a trivial example with two documents::
+ >>> base = {
+ >>> head = {
+We call the document we are merging changes into *base* and the changed
+document *head*. To merge these two documents using *jsonmerge*::
+ >>> from pprint import pprint
+ >>> from jsonmerge import merge
+ >>> result = merge(base, head)
+ >>> pprint(result, width=40)
+ {'bar': ['two'],
+ 'baz': 'Hello, world!',
+ 'foo': 1}
+As you can see, when encountering an JSON object, *jsonmerge* by default
+returns fields that appear in either *base* or *head* document. For other
+JSON types, it simply replaces the older value. These principles are also
+applied in case of multiple nested JSON objects.
+In a more realistic use case however, you might want to apply different
+*merge strategies* to different parts of the document. You can tell
+*jsonmerge* how to do that using a syntax based on `JSON schema`_.
+If you already have schemas for your document, you can simply expand them
+with some additional keywords. Apart from the custom keywords described
+below, *jsonmerge* by default uses the schema syntax defined in the `Draft
+4`_ of the JSON schema specification.
+You use the *mergeStrategy* schema keyword to specify the strategy. The
+default two strategies mentioned above are called *objectMerge* for objects
+and *overwrite* for all other types.
+Let's say you want to specify that the merged *bar* field in the example
+document above should contain elements from all documents, not just the
+latest one. You can do this with a schema like this::
+ >>> schema = {
+ >>> from jsonmerge import Merger
+ >>> merger = Merger(schema)
+ >>> result = merger.merge(base, head)
+ >>> pprint(result, width=40)
+ {'bar': ['one', 'two'],
+ 'baz': 'Hello, world!',
+ 'foo': 1}
+Another common example is when you need to keep a versioned list of values
+that appeared in the series of documents::
+ >>> schema = {
+ >>> from jsonmerge import Merger
+ >>> merger = Merger(schema)
+ >>> rev1 = {
+ >>> rev2 = {
+ >>> base = None
+ >>> base = merger.merge(base, rev1, merge_options={
+ >>> base = merger.merge(base, rev2, merge_options={
+ >>> pprint(base, width=55)
+ {'foo': [{'revision': 1,
+ 'value': {'greeting': 'Hello, World!'}},
+ {'revision': 2,
+ 'value': {'greeting': 'Howdy, World!'}}]}
+Note that we use the *mergeOptions* keyword in the schema to supply
+additional options to the merge strategy. In this case, we tell the
+*version* strategy to retain only 5 most recent versions of this field.
+We also used the *merge_options* argument to supply some options that are
+specific to each call of the *merge* method. Options specified this
+way are applied to all invocations of a specific strategy in a schema (in
+contrast to *mergeOptions*, which applies only to the strategy invocation
+in that specific location in the schema). Options specified in
+*mergeOptions* schema keyword override the options specified in the
+*merge_options* argument.
+The *metadata* option for the *version* strategy can contain some document
+meta-data that is included for each version of the field. *metadata* can
+contain an arbitrary JSON object.
+Example above also demonstrates how *jsonmerge* is typically used when
+merging more than two documents. Typically you start with an empty *base*
+and then consecutively merge different *heads* into it.
+A common source of problems are documents that do not match the schema used
+for merging. *jsonmerge* by itself does not validate input documents. It
+only uses the schema to obtain necessary information to apply appropriate merge
+strategies. Since the default strategies are used for parts of the
+document that are not covered by the schema it's easy to get unexpected
+output without any obvious errors raised by *jsonmerge*.
+In the following example, the property *Foo* (uppercase F) does not match
+*foo* (lowercase f) in the schema and hence the *version* strategy is not
+applied as with previous two revisions::
+ >>> rev3 = {
+ >>> base = merger.merge(base, rev3, merge_options={
+ >>> pprint(base, width=55)
+ {'Foo': {'greeting': 'Howdy, World!'},
+ 'foo': [{'revision': 1,
+ 'value': {'greeting': 'Hello, World!'}},
+ {'revision': 2,
+ 'value': {'greeting': 'Howdy, World!'}}]}
+Hence it is recommended to validate the input documents against the schema
+before passing them to *jsonmerge*. This practice is even more effective if
+the schema is filled in with more information than strictly necessary for
+*jsonmerge* (e.g. adding information about types, restrict valid object
+properties with *additionalProperties*, etc.)::
+ >>> from jsonschema import validate
+ >>> validate(rev1, schema)
+ >>> validate(rev2, schema)
+ >>> validate(rev3, schema)
+ Traceback (most recent call last):
+ jsonschema.exceptions.ValidationError: Additional properties are not allowed ('Foo' was unexpected)
+If you care about well-formedness of your documents, you might also want to
+obtain a schema for the documents that the *merge* method creates.
+*jsonmerge* provides a way to automatically generate it from a schema for
+the input document::
+ >>> result_schema = merger.get_schema()
+ >>> pprint(result_schema, width=80)
+ {'additionalProperties': False,
+ 'properties': {'foo': {'items': {'properties': {'value': {'type': 'object'}}},
+ 'maxItems': 5,
+ 'type': 'array'}}}
+Note that because of the *version* strategy, the type of the *foo* field
+changed from *object* to *array*.
+
+%package -n python3-jsonmerge
+Summary: Merge a series of JSON documents.
+Provides: python-jsonmerge
+BuildRequires: python3-devel
+BuildRequires: python3-setuptools
+BuildRequires: python3-pip
+%description -n python3-jsonmerge
+This Python module allows you to merge a series of JSON documents into a
+single one.
+This problem often occurs for example when different authors fill in
+different parts of a common document and you need to construct a document
+that includes contributions from all the authors. It also helps when
+dealing with consecutive versions of a document where different fields get
+updated over time.
+Consider a trivial example with two documents::
+ >>> base = {
+ >>> head = {
+We call the document we are merging changes into *base* and the changed
+document *head*. To merge these two documents using *jsonmerge*::
+ >>> from pprint import pprint
+ >>> from jsonmerge import merge
+ >>> result = merge(base, head)
+ >>> pprint(result, width=40)
+ {'bar': ['two'],
+ 'baz': 'Hello, world!',
+ 'foo': 1}
+As you can see, when encountering an JSON object, *jsonmerge* by default
+returns fields that appear in either *base* or *head* document. For other
+JSON types, it simply replaces the older value. These principles are also
+applied in case of multiple nested JSON objects.
+In a more realistic use case however, you might want to apply different
+*merge strategies* to different parts of the document. You can tell
+*jsonmerge* how to do that using a syntax based on `JSON schema`_.
+If you already have schemas for your document, you can simply expand them
+with some additional keywords. Apart from the custom keywords described
+below, *jsonmerge* by default uses the schema syntax defined in the `Draft
+4`_ of the JSON schema specification.
+You use the *mergeStrategy* schema keyword to specify the strategy. The
+default two strategies mentioned above are called *objectMerge* for objects
+and *overwrite* for all other types.
+Let's say you want to specify that the merged *bar* field in the example
+document above should contain elements from all documents, not just the
+latest one. You can do this with a schema like this::
+ >>> schema = {
+ >>> from jsonmerge import Merger
+ >>> merger = Merger(schema)
+ >>> result = merger.merge(base, head)
+ >>> pprint(result, width=40)
+ {'bar': ['one', 'two'],
+ 'baz': 'Hello, world!',
+ 'foo': 1}
+Another common example is when you need to keep a versioned list of values
+that appeared in the series of documents::
+ >>> schema = {
+ >>> from jsonmerge import Merger
+ >>> merger = Merger(schema)
+ >>> rev1 = {
+ >>> rev2 = {
+ >>> base = None
+ >>> base = merger.merge(base, rev1, merge_options={
+ >>> base = merger.merge(base, rev2, merge_options={
+ >>> pprint(base, width=55)
+ {'foo': [{'revision': 1,
+ 'value': {'greeting': 'Hello, World!'}},
+ {'revision': 2,
+ 'value': {'greeting': 'Howdy, World!'}}]}
+Note that we use the *mergeOptions* keyword in the schema to supply
+additional options to the merge strategy. In this case, we tell the
+*version* strategy to retain only 5 most recent versions of this field.
+We also used the *merge_options* argument to supply some options that are
+specific to each call of the *merge* method. Options specified this
+way are applied to all invocations of a specific strategy in a schema (in
+contrast to *mergeOptions*, which applies only to the strategy invocation
+in that specific location in the schema). Options specified in
+*mergeOptions* schema keyword override the options specified in the
+*merge_options* argument.
+The *metadata* option for the *version* strategy can contain some document
+meta-data that is included for each version of the field. *metadata* can
+contain an arbitrary JSON object.
+Example above also demonstrates how *jsonmerge* is typically used when
+merging more than two documents. Typically you start with an empty *base*
+and then consecutively merge different *heads* into it.
+A common source of problems are documents that do not match the schema used
+for merging. *jsonmerge* by itself does not validate input documents. It
+only uses the schema to obtain necessary information to apply appropriate merge
+strategies. Since the default strategies are used for parts of the
+document that are not covered by the schema it's easy to get unexpected
+output without any obvious errors raised by *jsonmerge*.
+In the following example, the property *Foo* (uppercase F) does not match
+*foo* (lowercase f) in the schema and hence the *version* strategy is not
+applied as with previous two revisions::
+ >>> rev3 = {
+ >>> base = merger.merge(base, rev3, merge_options={
+ >>> pprint(base, width=55)
+ {'Foo': {'greeting': 'Howdy, World!'},
+ 'foo': [{'revision': 1,
+ 'value': {'greeting': 'Hello, World!'}},
+ {'revision': 2,
+ 'value': {'greeting': 'Howdy, World!'}}]}
+Hence it is recommended to validate the input documents against the schema
+before passing them to *jsonmerge*. This practice is even more effective if
+the schema is filled in with more information than strictly necessary for
+*jsonmerge* (e.g. adding information about types, restrict valid object
+properties with *additionalProperties*, etc.)::
+ >>> from jsonschema import validate
+ >>> validate(rev1, schema)
+ >>> validate(rev2, schema)
+ >>> validate(rev3, schema)
+ Traceback (most recent call last):
+ jsonschema.exceptions.ValidationError: Additional properties are not allowed ('Foo' was unexpected)
+If you care about well-formedness of your documents, you might also want to
+obtain a schema for the documents that the *merge* method creates.
+*jsonmerge* provides a way to automatically generate it from a schema for
+the input document::
+ >>> result_schema = merger.get_schema()
+ >>> pprint(result_schema, width=80)
+ {'additionalProperties': False,
+ 'properties': {'foo': {'items': {'properties': {'value': {'type': 'object'}}},
+ 'maxItems': 5,
+ 'type': 'array'}}}
+Note that because of the *version* strategy, the type of the *foo* field
+changed from *object* to *array*.
+
+%package help
+Summary: Development documents and examples for jsonmerge
+Provides: python3-jsonmerge-doc
+%description help
+This Python module allows you to merge a series of JSON documents into a
+single one.
+This problem often occurs for example when different authors fill in
+different parts of a common document and you need to construct a document
+that includes contributions from all the authors. It also helps when
+dealing with consecutive versions of a document where different fields get
+updated over time.
+Consider a trivial example with two documents::
+ >>> base = {
+ >>> head = {
+We call the document we are merging changes into *base* and the changed
+document *head*. To merge these two documents using *jsonmerge*::
+ >>> from pprint import pprint
+ >>> from jsonmerge import merge
+ >>> result = merge(base, head)
+ >>> pprint(result, width=40)
+ {'bar': ['two'],
+ 'baz': 'Hello, world!',
+ 'foo': 1}
+As you can see, when encountering an JSON object, *jsonmerge* by default
+returns fields that appear in either *base* or *head* document. For other
+JSON types, it simply replaces the older value. These principles are also
+applied in case of multiple nested JSON objects.
+In a more realistic use case however, you might want to apply different
+*merge strategies* to different parts of the document. You can tell
+*jsonmerge* how to do that using a syntax based on `JSON schema`_.
+If you already have schemas for your document, you can simply expand them
+with some additional keywords. Apart from the custom keywords described
+below, *jsonmerge* by default uses the schema syntax defined in the `Draft
+4`_ of the JSON schema specification.
+You use the *mergeStrategy* schema keyword to specify the strategy. The
+default two strategies mentioned above are called *objectMerge* for objects
+and *overwrite* for all other types.
+Let's say you want to specify that the merged *bar* field in the example
+document above should contain elements from all documents, not just the
+latest one. You can do this with a schema like this::
+ >>> schema = {
+ >>> from jsonmerge import Merger
+ >>> merger = Merger(schema)
+ >>> result = merger.merge(base, head)
+ >>> pprint(result, width=40)
+ {'bar': ['one', 'two'],
+ 'baz': 'Hello, world!',
+ 'foo': 1}
+Another common example is when you need to keep a versioned list of values
+that appeared in the series of documents::
+ >>> schema = {
+ >>> from jsonmerge import Merger
+ >>> merger = Merger(schema)
+ >>> rev1 = {
+ >>> rev2 = {
+ >>> base = None
+ >>> base = merger.merge(base, rev1, merge_options={
+ >>> base = merger.merge(base, rev2, merge_options={
+ >>> pprint(base, width=55)
+ {'foo': [{'revision': 1,
+ 'value': {'greeting': 'Hello, World!'}},
+ {'revision': 2,
+ 'value': {'greeting': 'Howdy, World!'}}]}
+Note that we use the *mergeOptions* keyword in the schema to supply
+additional options to the merge strategy. In this case, we tell the
+*version* strategy to retain only 5 most recent versions of this field.
+We also used the *merge_options* argument to supply some options that are
+specific to each call of the *merge* method. Options specified this
+way are applied to all invocations of a specific strategy in a schema (in
+contrast to *mergeOptions*, which applies only to the strategy invocation
+in that specific location in the schema). Options specified in
+*mergeOptions* schema keyword override the options specified in the
+*merge_options* argument.
+The *metadata* option for the *version* strategy can contain some document
+meta-data that is included for each version of the field. *metadata* can
+contain an arbitrary JSON object.
+Example above also demonstrates how *jsonmerge* is typically used when
+merging more than two documents. Typically you start with an empty *base*
+and then consecutively merge different *heads* into it.
+A common source of problems are documents that do not match the schema used
+for merging. *jsonmerge* by itself does not validate input documents. It
+only uses the schema to obtain necessary information to apply appropriate merge
+strategies. Since the default strategies are used for parts of the
+document that are not covered by the schema it's easy to get unexpected
+output without any obvious errors raised by *jsonmerge*.
+In the following example, the property *Foo* (uppercase F) does not match
+*foo* (lowercase f) in the schema and hence the *version* strategy is not
+applied as with previous two revisions::
+ >>> rev3 = {
+ >>> base = merger.merge(base, rev3, merge_options={
+ >>> pprint(base, width=55)
+ {'Foo': {'greeting': 'Howdy, World!'},
+ 'foo': [{'revision': 1,
+ 'value': {'greeting': 'Hello, World!'}},
+ {'revision': 2,
+ 'value': {'greeting': 'Howdy, World!'}}]}
+Hence it is recommended to validate the input documents against the schema
+before passing them to *jsonmerge*. This practice is even more effective if
+the schema is filled in with more information than strictly necessary for
+*jsonmerge* (e.g. adding information about types, restrict valid object
+properties with *additionalProperties*, etc.)::
+ >>> from jsonschema import validate
+ >>> validate(rev1, schema)
+ >>> validate(rev2, schema)
+ >>> validate(rev3, schema)
+ Traceback (most recent call last):
+ jsonschema.exceptions.ValidationError: Additional properties are not allowed ('Foo' was unexpected)
+If you care about well-formedness of your documents, you might also want to
+obtain a schema for the documents that the *merge* method creates.
+*jsonmerge* provides a way to automatically generate it from a schema for
+the input document::
+ >>> result_schema = merger.get_schema()
+ >>> pprint(result_schema, width=80)
+ {'additionalProperties': False,
+ 'properties': {'foo': {'items': {'properties': {'value': {'type': 'object'}}},
+ 'maxItems': 5,
+ 'type': 'array'}}}
+Note that because of the *version* strategy, the type of the *foo* field
+changed from *object* to *array*.
+
+%prep
+%autosetup -n jsonmerge-1.9.0
+
+%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-jsonmerge -f filelist.lst
+%dir %{python3_sitelib}/*
+
+%files help -f doclist.lst
+%{_docdir}/*
+
+%changelog
+* Mon Apr 10 2023 Python_Bot <Python_Bot@openeuler.org> - 1.9.0-1
+- Package Spec generated
diff --git a/sources b/sources
new file mode 100644
index 0000000..af29e41
--- /dev/null
+++ b/sources
@@ -0,0 +1 @@
+c4fc601d805a31a16df6bdba74cd7dec jsonmerge-1.9.0.tar.gz