From 058398600a51046888bf45d729c8f8e293cb001e Mon Sep 17 00:00:00 2001 From: Daniel M Date: Tue, 23 Jul 2024 14:01:14 -0400 Subject: [PATCH] Migrate to pyproject.toml --- .github/workflows/test.yaml | 53 +++-- .gitignore | 1 + AUTHORS | 3 - LICENSE.txt => LICENSE | 0 MANIFEST.in | 4 - README.md | 13 +- jsonpointer/__init__.py | 58 ++++++ jsonpointer.py => jsonpointer/jsonpointer.py | 98 +++------ makefile | 17 -- poetry.lock | 201 +++++++++++++++++++ pyproject.toml | 74 +++++++ requirements-dev.txt | 4 - setup.cfg | 6 - setup.py | 66 ------ tests/__init__.py | 0 tests.py => tests/tests.py | 3 +- 16 files changed, 412 insertions(+), 189 deletions(-) delete mode 100644 AUTHORS rename LICENSE.txt => LICENSE (100%) delete mode 100644 MANIFEST.in create mode 100644 jsonpointer/__init__.py rename jsonpointer.py => jsonpointer/jsonpointer.py (66%) delete mode 100644 makefile create mode 100644 poetry.lock create mode 100644 pyproject.toml delete mode 100644 requirements-dev.txt delete mode 100644 setup.cfg delete mode 100644 setup.py create mode 100644 tests/__init__.py rename tests.py => tests/tests.py (99%) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index fa172c1..fd85508 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -19,19 +19,16 @@ jobs: with: ref: ${{ github.ref }} - - name: Set up Python 3.12 - uses: actions/setup-python@v5 + - name: "Setup Python, Poetry and Dependencies" + uses: dsoftwareinc/setup-python-poetry-action@v1 with: - python-version: 3.12 - allow-prereleases: true - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install flake8 + python-version: "3.12" + poetry-version: "1.8.3" + - name: Run flake8 shell: bash run: | - flake8 + poetry run flake8 test: needs: [ lint ] @@ -40,19 +37,43 @@ jobs: fail-fast: false matrix: python-version: [ "3.7", "3.8", "3.9", "3.10", "3.11", "3.12" ] + poetry-version: [ "1.8.3" ] + + exclude: + - python-version: "3.7" + poetry-version: "1.8.3" + include: + - python-version: "3.7" + poetry-version: "1.5.1" steps: - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 + + - name: "Setup Python, Poetry and Dependencies" + uses: dsoftwareinc/setup-python-poetry-action@v1 with: python-version: ${{ matrix.python-version }} - allow-prereleases: true - - name: Install dependencies + poetry-version: ${{ matrix.poetry-version }} + + - name: Test run: | - python -m pip install --upgrade pip - pip install -r requirements-dev.txt + poetry install --no-interaction + poetry run python -m unittest + + test-with-coverage: + needs: [ test ] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: "Setup Python, Poetry and Dependencies" + uses: dsoftwareinc/setup-python-poetry-action@v1 + with: + python-version: "3.12" + poetry-version: "1.8.3" - name: Test run: | - make coverage + poetry install --no-interaction + poetry run coverage run -m unittest + poetry run coverage report -m \ No newline at end of file diff --git a/.gitignore b/.gitignore index 861d6b2..584ded3 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ dist doc/_build *.egg-info .idea +.venv \ No newline at end of file diff --git a/AUTHORS b/AUTHORS deleted file mode 100644 index 8319fec..0000000 --- a/AUTHORS +++ /dev/null @@ -1,3 +0,0 @@ -Stefan Kögl -Alexander Shorin -Christopher J. White diff --git a/LICENSE.txt b/LICENSE similarity index 100% rename from LICENSE.txt rename to LICENSE diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 0f9b9f6..0000000 --- a/MANIFEST.in +++ /dev/null @@ -1,4 +0,0 @@ -include AUTHORS -include LICENSE.txt -include README.md -include tests.py diff --git a/README.md b/README.md index 06c8aef..f2180ed 100644 --- a/README.md +++ b/README.md @@ -5,17 +5,24 @@ python-json-pointer [![Supported Python versions](https://img.shields.io/pypi/pyversions/jsonpointer.svg)](https://pypi.python.org/pypi/jsonpointer/) [![Coverage Status](https://coveralls.io/repos/stefankoegl/python-json-pointer/badge.svg?branch=master)](https://coveralls.io/r/stefankoegl/python-json-pointer?branch=master) - -Resolve JSON Pointers in Python -------------------------------- +# Resolve JSON Pointers in Python Library to resolve JSON Pointers according to [RFC 6901](http://tools.ietf.org/html/rfc6901) See source code for examples + * Website: https://github.com/stefankoegl/python-json-pointer * Repository: https://github.com/stefankoegl/python-json-pointer.git * Documentation: https://python-json-pointer.readthedocs.org/ * PyPI: https://pypi.python.org/pypi/jsonpointer * Travis CI: https://travis-ci.org/stefankoegl/python-json-pointer * Coveralls: https://coveralls.io/r/stefankoegl/python-json-pointer + +# Installation + +Using pip: + +```bash +pip install jsonpointer +``` diff --git a/jsonpointer/__init__.py b/jsonpointer/__init__.py new file mode 100644 index 0000000..10e3107 --- /dev/null +++ b/jsonpointer/__init__.py @@ -0,0 +1,58 @@ +# -*- coding: utf-8 -*- +# +# python-json-pointer - An implementation of the JSON Pointer syntax +# https://github.com/stefankoegl/python-json-pointer +# +# 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. +# + +""" Identify specific nodes in a JSON document (RFC 6901) """ +from .jsonpointer import JsonPointerException, JsonPointer, resolve_pointer, set_pointer, EndOfList + +try: + from importlib import metadata +except ImportError: # for Python < 3.8 + import importlib_metadata as metadata # type: ignore + +# Will be parsed by setup.py to determine package metadata +jsonpointer_metadata = metadata.metadata("jsonpointer") +__author__ = jsonpointer_metadata["Author"] +__version__ = metadata.version("jsonpointer") +__website__ = jsonpointer_metadata["Home-page"] +__license__ = jsonpointer_metadata["License"] + +__all__ = [ + "resolve_pointer", + "set_pointer", + "JsonPointerException", + "JsonPointer", + "EndOfList", + "__author__", + "__version__", + "__website__", + "__license__", +] diff --git a/jsonpointer.py b/jsonpointer/jsonpointer.py similarity index 66% rename from jsonpointer.py rename to jsonpointer/jsonpointer.py index 3e97add..372fbbe 100644 --- a/jsonpointer.py +++ b/jsonpointer/jsonpointer.py @@ -1,43 +1,3 @@ -# -*- coding: utf-8 -*- -# -# python-json-pointer - An implementation of the JSON Pointer syntax -# https://github.com/stefankoegl/python-json-pointer -# -# 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. -# - -""" Identify specific nodes in a JSON document (RFC 6901) """ - -# Will be parsed by setup.py to determine package metadata -__author__ = 'Stefan Kögl ' -__version__ = '3.0.0' -__website__ = 'https://github.com/stefankoegl/python-json-pointer' -__license__ = 'Modified BSD License' - import copy import re from collections.abc import Mapping, Sequence @@ -73,7 +33,7 @@ def set_pointer(doc, pointer, value, inplace=True): def resolve_pointer(doc, pointer, default=_nothing): - """ Resolves pointer against doc and returns the referenced object + """Resolves pointer against doc and returns the referenced object >>> obj = {'foo': {'anArray': [ {'prop': 44}], 'another prop': {'baz': 'A string' }}, 'a%20b': 1, 'c d': 2} @@ -113,7 +73,7 @@ def resolve_pointer(doc, pointer, default=_nothing): def pairwise(iterable): - """ Transforms a list to a list of tuples of adjacent items + """Transforms a list to a list of tuples of adjacent items s -> (s0,s1), (s1,s2), (s2, s3), ... @@ -143,8 +103,7 @@ def __init__(self, list_): self.list_ = list_ def __repr__(self): - return '{cls}({lst})'.format(cls=self.__class__.__name__, - lst=repr(self.list_)) + return "{cls}({lst})".format(cls=self.__class__.__name__, lst=repr(self.list_)) class JsonPointer(object): @@ -152,20 +111,21 @@ class JsonPointer(object): # Array indices must not contain: # leading zeros, signs, spaces, decimals, etc - _RE_ARRAY_INDEX = re.compile('0|[1-9][0-9]*$') - _RE_INVALID_ESCAPE = re.compile('(~[^01]|~$)') + _RE_ARRAY_INDEX = re.compile("0|[1-9][0-9]*$") + _RE_INVALID_ESCAPE = re.compile("(~[^01]|~$)") def __init__(self, pointer): # validate escapes invalid_escape = self._RE_INVALID_ESCAPE.search(pointer) if invalid_escape: - raise JsonPointerException('Found invalid escape {}'.format( - invalid_escape.group())) + raise JsonPointerException( + "Found invalid escape {}".format(invalid_escape.group()) + ) - parts = pointer.split('/') - if parts.pop(0) != '': - raise JsonPointerException('Location must start with /') + parts = pointer.split("/") + if parts.pop(0) != "": + raise JsonPointerException("Location must start with /") parts = [unescape(part) for part in parts] self.parts = parts @@ -203,7 +163,7 @@ def set(self, doc, value, inplace=True): if len(self.parts) == 0: if inplace: - raise JsonPointerException('Cannot set root in place') + raise JsonPointerException("Cannot set root in place") return value if not inplace: @@ -211,7 +171,7 @@ def set(self, doc, value, inplace=True): (parent, part) = self.to_last(doc) - if isinstance(parent, Sequence) and part == '-': + if isinstance(parent, Sequence) and part == "-": parent.append(value) else: parent[part] = value @@ -227,7 +187,7 @@ def get_part(cls, doc, part): elif isinstance(doc, Sequence): - if part == '-': + if part == "-": return part if not JsonPointer._RE_ARRAY_INDEX.match(str(part)): @@ -235,14 +195,16 @@ def get_part(cls, doc, part): return int(part) - elif hasattr(doc, '__getitem__'): + elif hasattr(doc, "__getitem__"): # Allow indexing via ducktyping # if the target has defined __getitem__ return part else: - raise JsonPointerException("Document '%s' does not support indexing, " - "must be mapping/sequence or support __getitem__" % type(doc)) + raise JsonPointerException( + "Document '%s' does not support indexing, " + "must be mapping/sequence or support __getitem__" % type(doc) + ) def get_parts(self): """Returns the list of the parts. For example, JsonPointer('/a/b').get_parts() == ['a', 'b']""" @@ -250,14 +212,14 @@ def get_parts(self): return self.parts def walk(self, doc, part): - """ Walks one step in doc and returns the referenced part """ + """Walks one step in doc and returns the referenced part""" part = JsonPointer.get_part(doc, part) - assert hasattr(doc, '__getitem__'), "invalid document type %s" % (type(doc),) + assert hasattr(doc, "__getitem__"), "invalid document type %s" % (type(doc),) if isinstance(doc, Sequence): - if part == '-': + if part == "-": return EndOfList(doc) try: @@ -274,15 +236,15 @@ def walk(self, doc, part): raise JsonPointerException("member '%s' not found in %s" % (part, doc)) def contains(self, ptr): - """ Returns True if self contains the given ptr """ - return self.parts[:len(ptr.parts)] == ptr.parts + """Returns True if self contains the given ptr""" + return self.parts[: len(ptr.parts)] == ptr.parts def __contains__(self, item): - """ Returns True if self contains the given ptr """ + """Returns True if self contains the given ptr""" return self.contains(item) def join(self, suffix): - """ Returns a new JsonPointer with the given suffix append to this ptr """ + """Returns a new JsonPointer with the given suffix append to this ptr""" if isinstance(suffix, JsonPointer): suffix_parts = suffix.parts elif isinstance(suffix, str): @@ -304,7 +266,7 @@ def path(self): >>> ptr = JsonPointer('/~0/0/~1').path == '/~0/0/~1' """ parts = [escape(part) for part in self.parts] - return ''.join('/' + part for part in parts) + return "".join("/" + part for part in parts) def __eq__(self, other): """Compares a pointer to another object @@ -336,13 +298,13 @@ def from_parts(cls, parts): True """ parts = [escape(str(part)) for part in parts] - ptr = cls(''.join('/' + part for part in parts)) + ptr = cls("".join("/" + part for part in parts)) return ptr def escape(s): - return s.replace('~', '~0').replace('/', '~1') + return s.replace("~", "~0").replace("/", "~1") def unescape(s): - return s.replace('~1', '/').replace('~0', '~') + return s.replace("~1", "/").replace("~0", "~") diff --git a/makefile b/makefile deleted file mode 100644 index c40b485..0000000 --- a/makefile +++ /dev/null @@ -1,17 +0,0 @@ - -help: - @echo "jsonpointer" - @echo "Makefile targets" - @echo " - test: run tests" - @echo " - coverage: run tests with coverage" - @echo - @echo "To install jsonpointer, type" - @echo " python setup.py install" - @echo - -test: - python -munittest - -coverage: - coverage run --source=jsonpointer tests.py - coverage report -m diff --git a/poetry.lock b/poetry.lock new file mode 100644 index 0000000..1005580 --- /dev/null +++ b/poetry.lock @@ -0,0 +1,201 @@ +# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. + +[[package]] +name = "coverage" +version = "7.2.7" +description = "Code coverage measurement for Python" +optional = false +python-versions = ">=3.7" +files = [ + {file = "coverage-7.2.7-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:d39b5b4f2a66ccae8b7263ac3c8170994b65266797fb96cbbfd3fb5b23921db8"}, + {file = "coverage-7.2.7-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:6d040ef7c9859bb11dfeb056ff5b3872436e3b5e401817d87a31e1750b9ae2fb"}, + {file = "coverage-7.2.7-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ba90a9563ba44a72fda2e85302c3abc71c5589cea608ca16c22b9804262aaeb6"}, + {file = "coverage-7.2.7-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:e7d9405291c6928619403db1d10bd07888888ec1abcbd9748fdaa971d7d661b2"}, + {file = "coverage-7.2.7-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:31563e97dae5598556600466ad9beea39fb04e0229e61c12eaa206e0aa202063"}, + {file = "coverage-7.2.7-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:ebba1cd308ef115925421d3e6a586e655ca5a77b5bf41e02eb0e4562a111f2d1"}, + {file = "coverage-7.2.7-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:cb017fd1b2603ef59e374ba2063f593abe0fc45f2ad9abdde5b4d83bd922a353"}, + {file = "coverage-7.2.7-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:d62a5c7dad11015c66fbb9d881bc4caa5b12f16292f857842d9d1871595f4495"}, + {file = "coverage-7.2.7-cp310-cp310-win32.whl", hash = "sha256:ee57190f24fba796e36bb6d3aa8a8783c643d8fa9760c89f7a98ab5455fbf818"}, + {file = "coverage-7.2.7-cp310-cp310-win_amd64.whl", hash = "sha256:f75f7168ab25dd93110c8a8117a22450c19976afbc44234cbf71481094c1b850"}, + {file = "coverage-7.2.7-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:06a9a2be0b5b576c3f18f1a241f0473575c4a26021b52b2a85263a00f034d51f"}, + {file = "coverage-7.2.7-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:5baa06420f837184130752b7c5ea0808762083bf3487b5038d68b012e5937dbe"}, + {file = "coverage-7.2.7-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:fdec9e8cbf13a5bf63290fc6013d216a4c7232efb51548594ca3631a7f13c3a3"}, + {file = "coverage-7.2.7-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:52edc1a60c0d34afa421c9c37078817b2e67a392cab17d97283b64c5833f427f"}, + {file = "coverage-7.2.7-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:63426706118b7f5cf6bb6c895dc215d8a418d5952544042c8a2d9fe87fcf09cb"}, + {file = "coverage-7.2.7-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:afb17f84d56068a7c29f5fa37bfd38d5aba69e3304af08ee94da8ed5b0865833"}, + {file = "coverage-7.2.7-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:48c19d2159d433ccc99e729ceae7d5293fbffa0bdb94952d3579983d1c8c9d97"}, + {file = "coverage-7.2.7-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:0e1f928eaf5469c11e886fe0885ad2bf1ec606434e79842a879277895a50942a"}, + {file = "coverage-7.2.7-cp311-cp311-win32.whl", hash = "sha256:33d6d3ea29d5b3a1a632b3c4e4f4ecae24ef170b0b9ee493883f2df10039959a"}, + {file = "coverage-7.2.7-cp311-cp311-win_amd64.whl", hash = "sha256:5b7540161790b2f28143191f5f8ec02fb132660ff175b7747b95dcb77ac26562"}, + {file = "coverage-7.2.7-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:f2f67fe12b22cd130d34d0ef79206061bfb5eda52feb6ce0dba0644e20a03cf4"}, + {file = "coverage-7.2.7-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a342242fe22407f3c17f4b499276a02b01e80f861f1682ad1d95b04018e0c0d4"}, + {file = "coverage-7.2.7-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:171717c7cb6b453aebac9a2ef603699da237f341b38eebfee9be75d27dc38e01"}, + {file = "coverage-7.2.7-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:49969a9f7ffa086d973d91cec8d2e31080436ef0fb4a359cae927e742abfaaa6"}, + {file = "coverage-7.2.7-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:b46517c02ccd08092f4fa99f24c3b83d8f92f739b4657b0f146246a0ca6a831d"}, + {file = "coverage-7.2.7-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:a3d33a6b3eae87ceaefa91ffdc130b5e8536182cd6dfdbfc1aa56b46ff8c86de"}, + {file = "coverage-7.2.7-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:976b9c42fb2a43ebf304fa7d4a310e5f16cc99992f33eced91ef6f908bd8f33d"}, + {file = "coverage-7.2.7-cp312-cp312-win32.whl", hash = "sha256:8de8bb0e5ad103888d65abef8bca41ab93721647590a3f740100cd65c3b00511"}, + {file = "coverage-7.2.7-cp312-cp312-win_amd64.whl", hash = "sha256:9e31cb64d7de6b6f09702bb27c02d1904b3aebfca610c12772452c4e6c21a0d3"}, + {file = "coverage-7.2.7-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:58c2ccc2f00ecb51253cbe5d8d7122a34590fac9646a960d1430d5b15321d95f"}, + {file = "coverage-7.2.7-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d22656368f0e6189e24722214ed8d66b8022db19d182927b9a248a2a8a2f67eb"}, + {file = "coverage-7.2.7-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a895fcc7b15c3fc72beb43cdcbdf0ddb7d2ebc959edac9cef390b0d14f39f8a9"}, + {file = "coverage-7.2.7-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e84606b74eb7de6ff581a7915e2dab7a28a0517fbe1c9239eb227e1354064dcd"}, + {file = "coverage-7.2.7-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:0a5f9e1dbd7fbe30196578ca36f3fba75376fb99888c395c5880b355e2875f8a"}, + {file = "coverage-7.2.7-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:419bfd2caae268623dd469eff96d510a920c90928b60f2073d79f8fe2bbc5959"}, + {file = "coverage-7.2.7-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:2aee274c46590717f38ae5e4650988d1af340fe06167546cc32fe2f58ed05b02"}, + {file = "coverage-7.2.7-cp37-cp37m-win32.whl", hash = "sha256:61b9a528fb348373c433e8966535074b802c7a5d7f23c4f421e6c6e2f1697a6f"}, + {file = "coverage-7.2.7-cp37-cp37m-win_amd64.whl", hash = "sha256:b1c546aca0ca4d028901d825015dc8e4d56aac4b541877690eb76490f1dc8ed0"}, + {file = "coverage-7.2.7-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:54b896376ab563bd38453cecb813c295cf347cf5906e8b41d340b0321a5433e5"}, + {file = "coverage-7.2.7-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:3d376df58cc111dc8e21e3b6e24606b5bb5dee6024f46a5abca99124b2229ef5"}, + {file = "coverage-7.2.7-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5e330fc79bd7207e46c7d7fd2bb4af2963f5f635703925543a70b99574b0fea9"}, + {file = "coverage-7.2.7-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1e9d683426464e4a252bf70c3498756055016f99ddaec3774bf368e76bbe02b6"}, + {file = "coverage-7.2.7-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8d13c64ee2d33eccf7437961b6ea7ad8673e2be040b4f7fd4fd4d4d28d9ccb1e"}, + {file = "coverage-7.2.7-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:b7aa5f8a41217360e600da646004f878250a0d6738bcdc11a0a39928d7dc2050"}, + {file = "coverage-7.2.7-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:8fa03bce9bfbeeef9f3b160a8bed39a221d82308b4152b27d82d8daa7041fee5"}, + {file = "coverage-7.2.7-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:245167dd26180ab4c91d5e1496a30be4cd721a5cf2abf52974f965f10f11419f"}, + {file = "coverage-7.2.7-cp38-cp38-win32.whl", hash = "sha256:d2c2db7fd82e9b72937969bceac4d6ca89660db0a0967614ce2481e81a0b771e"}, + {file = "coverage-7.2.7-cp38-cp38-win_amd64.whl", hash = "sha256:2e07b54284e381531c87f785f613b833569c14ecacdcb85d56b25c4622c16c3c"}, + {file = "coverage-7.2.7-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:537891ae8ce59ef63d0123f7ac9e2ae0fc8b72c7ccbe5296fec45fd68967b6c9"}, + {file = "coverage-7.2.7-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:06fb182e69f33f6cd1d39a6c597294cff3143554b64b9825d1dc69d18cc2fff2"}, + {file = "coverage-7.2.7-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:201e7389591af40950a6480bd9edfa8ed04346ff80002cec1a66cac4549c1ad7"}, + {file = "coverage-7.2.7-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:f6951407391b639504e3b3be51b7ba5f3528adbf1a8ac3302b687ecababf929e"}, + {file = "coverage-7.2.7-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6f48351d66575f535669306aa7d6d6f71bc43372473b54a832222803eb956fd1"}, + {file = "coverage-7.2.7-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:b29019c76039dc3c0fd815c41392a044ce555d9bcdd38b0fb60fb4cd8e475ba9"}, + {file = "coverage-7.2.7-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:81c13a1fc7468c40f13420732805a4c38a105d89848b7c10af65a90beff25250"}, + {file = "coverage-7.2.7-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:975d70ab7e3c80a3fe86001d8751f6778905ec723f5b110aed1e450da9d4b7f2"}, + {file = "coverage-7.2.7-cp39-cp39-win32.whl", hash = "sha256:7ee7d9d4822c8acc74a5e26c50604dff824710bc8de424904c0982e25c39c6cb"}, + {file = "coverage-7.2.7-cp39-cp39-win_amd64.whl", hash = "sha256:eb393e5ebc85245347950143969b241d08b52b88a3dc39479822e073a1a8eb27"}, + {file = "coverage-7.2.7-pp37.pp38.pp39-none-any.whl", hash = "sha256:b7b4c971f05e6ae490fef852c218b0e79d4e52f79ef0c8475566584a8fb3e01d"}, + {file = "coverage-7.2.7.tar.gz", hash = "sha256:924d94291ca674905fe9481f12294eb11f2d3d3fd1adb20314ba89e94f44ed59"}, +] + +[package.extras] +toml = ["tomli"] + +[[package]] +name = "flake8" +version = "7.1.0" +description = "the modular source code checker: pep8 pyflakes and co" +optional = false +python-versions = ">=3.8.1" +files = [ + {file = "flake8-7.1.0-py2.py3-none-any.whl", hash = "sha256:2e416edcc62471a64cea09353f4e7bdba32aeb079b6e360554c659a122b1bc6a"}, + {file = "flake8-7.1.0.tar.gz", hash = "sha256:48a07b626b55236e0fb4784ee69a465fbf59d79eec1f5b4785c3d3bc57d17aa5"}, +] + +[package.dependencies] +mccabe = ">=0.7.0,<0.8.0" +pycodestyle = ">=2.12.0,<2.13.0" +pyflakes = ">=3.2.0,<3.3.0" + +[[package]] +name = "flake8-pyproject" +version = "1.2.3" +description = "Flake8 plug-in loading the configuration from pyproject.toml" +optional = false +python-versions = ">= 3.6" +files = [ + {file = "flake8_pyproject-1.2.3-py3-none-any.whl", hash = "sha256:6249fe53545205af5e76837644dc80b4c10037e73a0e5db87ff562d75fb5bd4a"}, +] + +[package.dependencies] +Flake8 = ">=5" +TOMLi = {version = "*", markers = "python_version < \"3.11\""} + +[package.extras] +dev = ["pyTest", "pyTest-cov"] + +[[package]] +name = "importlib-metadata" +version = "4.13.0" +description = "Read metadata from Python packages" +optional = false +python-versions = ">=3.7" +files = [ + {file = "importlib_metadata-4.13.0-py3-none-any.whl", hash = "sha256:8a8a81bcf996e74fee46f0d16bd3eaa382a7eb20fd82445c3ad11f4090334116"}, + {file = "importlib_metadata-4.13.0.tar.gz", hash = "sha256:dd0173e8f150d6815e098fd354f6414b0f079af4644ddfe90c71e2fc6174346d"}, +] + +[package.dependencies] +typing-extensions = {version = ">=3.6.4", markers = "python_version < \"3.8\""} +zipp = ">=0.5" + +[package.extras] +docs = ["furo", "jaraco.packaging (>=9)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)"] +perf = ["ipython"] +testing = ["flake8 (<5)", "flufl.flake8", "importlib-resources (>=1.3)", "packaging", "pyfakefs", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.3)", "pytest-flake8", "pytest-mypy (>=0.9.1)", "pytest-perf (>=0.9.2)"] + +[[package]] +name = "mccabe" +version = "0.7.0" +description = "McCabe checker, plugin for flake8" +optional = false +python-versions = ">=3.6" +files = [ + {file = "mccabe-0.7.0-py2.py3-none-any.whl", hash = "sha256:6c2d30ab6be0e4a46919781807b4f0d834ebdd6c6e3dca0bda5a15f863427b6e"}, + {file = "mccabe-0.7.0.tar.gz", hash = "sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325"}, +] + +[[package]] +name = "pycodestyle" +version = "2.12.0" +description = "Python style guide checker" +optional = false +python-versions = ">=3.8" +files = [ + {file = "pycodestyle-2.12.0-py2.py3-none-any.whl", hash = "sha256:949a39f6b86c3e1515ba1787c2022131d165a8ad271b11370a8819aa070269e4"}, + {file = "pycodestyle-2.12.0.tar.gz", hash = "sha256:442f950141b4f43df752dd303511ffded3a04c2b6fb7f65980574f0c31e6e79c"}, +] + +[[package]] +name = "pyflakes" +version = "3.2.0" +description = "passive checker of Python programs" +optional = false +python-versions = ">=3.8" +files = [ + {file = "pyflakes-3.2.0-py2.py3-none-any.whl", hash = "sha256:84b5be138a2dfbb40689ca07e2152deb896a65c3a3e24c251c5c62489568074a"}, + {file = "pyflakes-3.2.0.tar.gz", hash = "sha256:1c61603ff154621fb2a9172037d84dca3500def8c8b630657d1701f026f8af3f"}, +] + +[[package]] +name = "tomli" +version = "2.0.1" +description = "A lil' TOML parser" +optional = false +python-versions = ">=3.7" +files = [ + {file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"}, + {file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"}, +] + +[[package]] +name = "typing-extensions" +version = "4.7.1" +description = "Backported and Experimental Type Hints for Python 3.7+" +optional = false +python-versions = ">=3.7" +files = [ + {file = "typing_extensions-4.7.1-py3-none-any.whl", hash = "sha256:440d5dd3af93b060174bf433bccd69b0babc3b15b1a8dca43789fd7f61514b36"}, + {file = "typing_extensions-4.7.1.tar.gz", hash = "sha256:b75ddc264f0ba5615db7ba217daeb99701ad295353c45f9e95963337ceeeffb2"}, +] + +[[package]] +name = "zipp" +version = "3.15.0" +description = "Backport of pathlib-compatible object wrapper for zip files" +optional = false +python-versions = ">=3.7" +files = [ + {file = "zipp-3.15.0-py3-none-any.whl", hash = "sha256:48904fc76a60e542af151aded95726c1a5c34ed43ab4134b597665c86d7ad556"}, + {file = "zipp-3.15.0.tar.gz", hash = "sha256:112929ad649da941c23de50f356a2b5570c954b65150642bccdd66bf194d224b"}, +] + +[package.extras] +docs = ["furo", "jaraco.packaging (>=9)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-lint"] +testing = ["big-O", "flake8 (<5)", "jaraco.functools", "jaraco.itertools", "more-itertools", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.3)", "pytest-flake8", "pytest-mypy (>=0.9.1)"] + +[metadata] +lock-version = "2.0" +python-versions = "^3.7" +content-hash = "fcccbf4dc2dfa9308f3348bf0d4ff378cdbf33a75b30fc27de1a1e85995339f8" diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..ef2bff4 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,74 @@ +[build-system] +requires = ["poetry_core"] +build-backend = "poetry.core.masonry.api" + +[tool.poetry.scripts] +jsonpointer = "bin.jsonpointer:main" + +[tool.poetry] +name = "jsonpointer" +packages = [ + { include = "jsonpointer" }, + { include = "README.md" }, + { include = "LICENSE" }, + { include = "tests" }, +] +version = "3.0.1" +description = "Resolve JSON Pointers in Python" +readme = "README.md" +keywords = ["json", "pointer", "rfc6901"] +authors = [ + "Stefan Kögl ", + "Daniel Moran ", + "Alexander Shorin ", + "Christopher J. White ", +] +maintainers = [ + "Daniel Moran ", +] +license = "Modified BSD License" +classifiers = [ + 'Development Status :: 5 - Production/Stable', + 'Environment :: Console', + 'Intended Audience :: Developers', + 'License :: OSI Approved :: BSD License', + 'Operating System :: OS Independent', + 'Programming Language :: Python', + 'Programming Language :: Python :: 3', + '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 :: 3.13', + 'Programming Language :: Python :: Implementation :: CPython', + 'Programming Language :: Python :: Implementation :: PyPy', + 'Topic :: Software Development :: Libraries', + 'Topic :: Utilities', +] +homepage = "https://github.com/stefankoegl/python-json-pointer" +repository = "https://github.com/stefankoegl/python-json-pointer" + +[tool.poetry.dependencies] +python = "^3.7" +importlib-metadata = { version = "^4.8.1", python = "<3.8" } + +[tool.poetry.group.dev.dependencies] +coverage = "^7" +flake8 = { version = "^7.1", python = ">=3.8.1" } +flake8-pyproject = { version = "^1.2.3", python = ">=3.8.1" } + +[tool.flake8] +max-line-length = 120 +exclude = [ + ".git", + ".tox", + "dist", + "doc", + "*egg", + "build", + ".venv", + ".github", + "__pycache__", +] diff --git a/requirements-dev.txt b/requirements-dev.txt deleted file mode 100644 index 239fcca..0000000 --- a/requirements-dev.txt +++ /dev/null @@ -1,4 +0,0 @@ -wheel -setuptools -coverage -flake8 diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index ab8f354..0000000 --- a/setup.cfg +++ /dev/null @@ -1,6 +0,0 @@ -[bdist_wheel] -universal = 1 - -[flake8] -max-line-length = 120 -exclude = .git,.tox,dist,doc,*egg,build,.venv \ No newline at end of file diff --git a/setup.py b/setup.py deleted file mode 100644 index 3e87a4c..0000000 --- a/setup.py +++ /dev/null @@ -1,66 +0,0 @@ -#!/usr/bin/env python - -import io -import os.path -import re - -from setuptools import setup - -dirname = os.path.dirname(os.path.abspath(__file__)) -filename = os.path.join(dirname, 'jsonpointer.py') -src = io.open(filename, encoding='utf-8').read() -metadata = dict(re.findall("__([a-z]+)__ = '([^']+)'", src)) -docstrings = re.findall('"""(.*)"""', src) - -PACKAGE = 'jsonpointer' - -MODULES = ( - 'jsonpointer', -) - -AUTHOR_EMAIL = metadata['author'] -VERSION = metadata['version'] -WEBSITE = metadata['website'] -LICENSE = metadata['license'] -DESCRIPTION = docstrings[0] - -# Extract name and e-mail ("Firstname Lastname ") -AUTHOR, EMAIL = re.match(r'(.*) <(.*)>', AUTHOR_EMAIL).groups() - -with open('README.md') as readme: - long_description = readme.read() - -CLASSIFIERS = [ - 'Development Status :: 5 - Production/Stable', - 'Environment :: Console', - 'Intended Audience :: Developers', - 'License :: OSI Approved :: BSD License', - 'Operating System :: OS Independent', - 'Programming Language :: Python', - 'Programming Language :: Python :: 3', - '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', - 'Topic :: Utilities', -] - -setup(name=PACKAGE, - version=VERSION, - description=DESCRIPTION, - long_description=long_description, - long_description_content_type="text/markdown", - author=AUTHOR, - author_email=EMAIL, - license=LICENSE, - url=WEBSITE, - py_modules=MODULES, - scripts=['bin/jsonpointer'], - classifiers=CLASSIFIERS, - python_requires='>=3.7', - ) diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests.py b/tests/tests.py similarity index 99% rename from tests.py rename to tests/tests.py index 7b1cdac..7ee6b52 100755 --- a/tests.py +++ b/tests/tests.py @@ -9,8 +9,7 @@ import unittest import jsonpointer -from jsonpointer import resolve_pointer, EndOfList, JsonPointerException, \ - JsonPointer, set_pointer +from jsonpointer import (resolve_pointer, EndOfList, JsonPointerException, JsonPointer, set_pointer) class SpecificationTests(unittest.TestCase):