From a76f742dcfb7a4b0fb0ab2bec4bb4e54a7ebb3ef Mon Sep 17 00:00:00 2001 From: Hiroshi Miura <6115787+hirmiura@users.noreply.github.com> Date: Sat, 17 Jun 2023 05:06:12 +0900 Subject: [PATCH 1/8] feat(jsondiff): Add support for preserving Unicode characters (#145) Mostly same as https://github.com/stefankoegl/python-json-patch/pull/127 --- bin/jsondiff | 4 +++- doc/commandline.rst | 9 +++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/bin/jsondiff b/bin/jsondiff index b79188b..5ac0090 100755 --- a/bin/jsondiff +++ b/bin/jsondiff @@ -14,6 +14,8 @@ parser.add_argument('FILE1', type=argparse.FileType('r')) parser.add_argument('FILE2', type=argparse.FileType('r')) parser.add_argument('--indent', type=int, default=None, help='Indent output by n spaces') +parser.add_argument('-u', '--preserve-unicode', action='store_true', + help='Output Unicode character as-is without using Code Point') parser.add_argument('-v', '--version', action='version', version='%(prog)s ' + jsonpatch.__version__) @@ -32,7 +34,7 @@ def diff_files(): doc2 = json.load(args.FILE2) patch = jsonpatch.make_patch(doc1, doc2) if patch.patch: - print(json.dumps(patch.patch, indent=args.indent)) + print(json.dumps(patch.patch, indent=args.indent, ensure_ascii=not(args.preserve_unicode))) sys.exit(1) if __name__ == "__main__": diff --git a/doc/commandline.rst b/doc/commandline.rst index 5fb9a3c..a7a78d8 100644 --- a/doc/commandline.rst +++ b/doc/commandline.rst @@ -10,7 +10,7 @@ The JSON patch package contains the commandline utilities ``jsondiff`` and The program ``jsondiff`` can be used to create a JSON patch by comparing two JSON files :: - usage: jsondiff [-h] [--indent INDENT] [-v] FILE1 FILE2 + usage: jsondiff [-h] [--indent INDENT] [-u] [-v] FILE1 FILE2 Diff two JSON files @@ -19,9 +19,10 @@ JSON files :: FILE2 optional arguments: - -h, --help show this help message and exit - --indent INDENT Indent output by n spaces - -v, --version show program's version number and exit + -h, --help show this help message and exit + --indent INDENT Indent output by n spaces + -u, --preserve-unicode Output Unicode character as-is without using Code Point + -v, --version show program's version number and exit Example ^^^^^^^ From 33562b0d685ced527ee635ac14bf01fbe3c94ad0 Mon Sep 17 00:00:00 2001 From: Tim Poulsen Date: Fri, 16 Jun 2023 16:07:28 -0400 Subject: [PATCH 2/8] Update license text to match official 3-clause-BSD (#142) --- COPYING | 26 -------------------------- LICENSE | 11 +++++++++++ 2 files changed, 11 insertions(+), 26 deletions(-) delete mode 100644 COPYING create mode 100644 LICENSE diff --git a/COPYING b/COPYING deleted file mode 100644 index 491196d..0000000 --- a/COPYING +++ /dev/null @@ -1,26 +0,0 @@ -Copyright (c) 2011 Stefan Kögl -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. -3. The name of the author may not be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..c8fc60f --- /dev/null +++ b/LICENSE @@ -0,0 +1,11 @@ +Copyright (c) 2011 Stefan Kögl + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. From 45cfe90c84985ac50f6c34d6124294c2f0898379 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20K=C3=B6gl?= Date: Fri, 16 Jun 2023 22:41:43 +0200 Subject: [PATCH 3/8] Switch to GitHub actions (#144) * Switch to GitHub actions * add support for Python 3.11, remove 3.5, 3.6 --- .github/workflows/test.yaml | 34 ++++++++++++++++++++++++++++++++++ .travis.yml | 33 --------------------------------- setup.py | 4 +--- 3 files changed, 35 insertions(+), 36 deletions(-) create mode 100644 .github/workflows/test.yaml delete mode 100644 .travis.yml diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..639e18d --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,34 @@ +name: Python package + +on: [push] + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: ["2.7", "3.7", "3.8", "3.9", "3.10", "3.11"] + + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install flake8 pytest + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + pip install coveralls +# - name: Lint with flake8 +# run: | + # stop the build if there are Python syntax errors or undefined names + # flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + # flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Test + run: | + coverage run --source=jsonpointer tests.py diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 865f8fa..0000000 --- a/.travis.yml +++ /dev/null @@ -1,33 +0,0 @@ -dist: xenial -language: python -python: -- '2.7' -- '3.5' -- '3.6' -- '3.7' -- '3.8' -- '3.9' -- 3.10-dev -- nightly -- pypy3 -addons: - apt: - packages: - - pandoc -install: -- travis_retry pip install -r requirements.txt -- travis_retry pip install coveralls -script: -- coverage run --source=jsonpointer tests.py -after_script: -- coveralls -before_deploy: -- pip install -r requirements-dev.txt -deploy: - provider: pypi - user: skoegl - password: - secure: ppMhKu82oIig1INyiNkt9veOd5FUUIKFUXj2TzxMSdzPtzAhQnScJMGPEtPfH8MwXng/CtJiDWS6zJzRFsW/3Ch+JHPkOtxOfkopBs1t1SpCyqNPSvf6Zxh83Dg6Bq6+8GyVW1RPuNIGflsvzY2C3z5i79FQXwZd8EQlg7Vu0Wo= - on: - tags: true - distributions: sdist bdist_wheel diff --git a/setup.py b/setup.py index ad43bd5..7753be1 100644 --- a/setup.py +++ b/setup.py @@ -56,8 +56,6 @@ 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.5', - 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', @@ -80,7 +78,7 @@ package_data={'': ['requirements.txt']}, scripts=['bin/jsondiff', 'bin/jsonpatch'], classifiers=CLASSIFIERS, - python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*', + python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, !=3.6.*', project_urls={ 'Website': 'https://github.com/stefankoegl/python-json-patch', 'Repository': 'https://github.com/stefankoegl/python-json-patch.git', From 0b0520328504050ee09d835d4df294838e055c38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20K=C3=B6gl?= Date: Fri, 16 Jun 2023 22:43:04 +0200 Subject: [PATCH 4/8] bump version to 1.33 --- jsonpatch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jsonpatch.py b/jsonpatch.py index a4bd519..d3fc26d 100644 --- a/jsonpatch.py +++ b/jsonpatch.py @@ -67,7 +67,7 @@ # Will be parsed by setup.py to determine package metadata __author__ = 'Stefan Kögl ' -__version__ = '1.32' +__version__ = '1.33' __website__ = 'https://github.com/stefankoegl/python-json-patch' __license__ = 'Modified BSD License' From e5a007a76998b1a2309d8c6cfc474d7ff4a870de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20K=C3=B6gl?= Date: Fri, 16 Jun 2023 23:22:18 +0200 Subject: [PATCH 5/8] add .readthedocs.yaml https://blog.readthedocs.com/migrate-configuration-v2/ --- .readthedocs.yaml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .readthedocs.yaml diff --git a/.readthedocs.yaml b/.readthedocs.yaml new file mode 100644 index 0000000..b8c2f2b --- /dev/null +++ b/.readthedocs.yaml @@ -0,0 +1,22 @@ +# .readthedocs.yaml +# Read the Docs configuration file +# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details + +# Required +version: 2 + +# Set the version of Python and other tools you might need +build: + os: ubuntu-22.04 + tools: + python: "3.11" + +# Build documentation in the docs/ directory with Sphinx +sphinx: + configuration: doc/conf.py + +# We recommend specifying your dependencies to enable reproducible builds: +# https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html +# python: +# install: +# - requirements: docs/requirements.txt From 73c36f2c4776c008cd4e750f5240e06dfdc918fc Mon Sep 17 00:00:00 2001 From: Andrew Garrett Date: Wed, 28 Jun 2023 14:01:39 +1000 Subject: [PATCH 6/8] Update documentation to include a link to the GitHub repo and installation instructions (#147) --- doc/index.rst | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/doc/index.rst b/doc/index.rst index 2f46921..b97b82b 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -6,10 +6,15 @@ python-json-patch ================= -*python-json-patch* is a Python library for applying JSON patches (`RFC 6902 +`python-json-patch `_ +is a Python library for applying JSON patches (`RFC 6902 `_). Python 2.7 and 3.4+ are supported. Tests are run on both CPython and PyPy. +**Installation** +.. code-block:: bash + $ pip install jsonpatch +.. **Contents** From a22e05a16d746c772802b51c57bdae55b6564723 Mon Sep 17 00:00:00 2001 From: konstantin Date: Sat, 24 Feb 2024 17:04:16 +0100 Subject: [PATCH 7/8] chore: add Python 3.10-3.12 as supported versions (#156) --- setup.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/setup.py b/setup.py index 7753be1..ab9f32a 100644 --- a/setup.py +++ b/setup.py @@ -59,6 +59,9 @@ 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', 'Programming Language :: Python :: Implementation :: CPython', 'Programming Language :: Python :: Implementation :: PyPy', 'Topic :: Software Development :: Libraries', From d8e1a6e244728c04229d601bc9a384d9b034c603 Mon Sep 17 00:00:00 2001 From: CyrilRoelandteNovance Date: Mon, 5 Aug 2024 22:10:52 +0200 Subject: [PATCH 8/8] Fix tests for Python 3.12 (#162) unittest.TestCase.assertEquals has been removed in Python 3.12; unittest.TestCase.assertEqual should be used instead[1]. [1] https://docs.python.org/3/whatsnew/3.12.html#id3 --- ext_tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext_tests.py b/ext_tests.py index 1fd8d8f..59a36d2 100755 --- a/ext_tests.py +++ b/ext_tests.py @@ -67,7 +67,7 @@ def _test(self, test): # if there is no 'expected' we only verify that applying the patch # does not raise an exception if 'expected' in test: - self.assertEquals(res, test['expected'], test.get('comment', '')) + self.assertEqual(res, test['expected'], test.get('comment', '')) def make_test_case(tests):