pax_global_header00006660000000000000000000000064143042313040014504gustar00rootroot0000000000000052 comment=ffe38191c91b9dc154d8cedb67567bad460473f6 pathable-0.4.3/000077500000000000000000000000001430423130400132705ustar00rootroot00000000000000pathable-0.4.3/.bumpversion.cfg000066400000000000000000000005551430423130400164050ustar00rootroot00000000000000[bumpversion] current_version = 0.4.3 tag = True tag_name = {new_version} commit = True message = Version {new_version} parse = (?P\d+)\.(?P\d+)\.(?P\d+) serialize = {major}.{minor}.{patch} [bumpversion:file:pathable/__init__.py] [bumpversion:file:pyproject.toml] search = version = "{current_version}" replace = version = "{new_version}" pathable-0.4.3/.github/000077500000000000000000000000001430423130400146305ustar00rootroot00000000000000pathable-0.4.3/.github/FUNDING.yml000066400000000000000000000000201430423130400164350ustar00rootroot00000000000000github: [p1c2u] pathable-0.4.3/.github/workflows/000077500000000000000000000000001430423130400166655ustar00rootroot00000000000000pathable-0.4.3/.github/workflows/python-publish.yml000066400000000000000000000017551430423130400224050ustar00rootroot00000000000000# This workflow will upload a Python Package using Twine when a release is created # For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries name: Publish python packages on: workflow_dispatch: release: types: - created jobs: publish: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Set up Python uses: actions/setup-python@v2 with: python-version: '3.x' - name: Bootstrap poetry run: | curl -sL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py | python - -y echo "$HOME/.local/bin" >> $GITHUB_PATH - name: Build run: poetry build - name: Publish env: POETRY_HTTP_BASIC_PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }} POETRY_HTTP_BASIC_PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }} run: poetry publish pathable-0.4.3/.github/workflows/python-test.yml000066400000000000000000000034471430423130400217160ustar00rootroot00000000000000# This workflow will install Python dependencies, run tests and lint with a variety of Python versions # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions name: Test python code on: push: pull_request: types: [opened, synchronize] jobs: test: name: "Tests" runs-on: ubuntu-latest strategy: matrix: python-version: ['3.7', '3.8', '3.9', '3.10'] fail-fast: false steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} - name: Get full Python version id: full-python-version run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))") - name: Bootstrap poetry run: | python -m pip install --upgrade pip pip install "poetry<1.2" - name: Configure poetry run: poetry config virtualenvs.in-project true - name: Set up cache uses: actions/cache@v2 id: cache with: path: .venv key: venv-${{ github.event_name }}-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }} - name: Ensure cache is healthy if: steps.cache.outputs.cache-hit == 'true' shell: bash run: timeout 10s poetry run pip --version || rm -rf .venv - name: Install dependencies run: poetry install - name: Test env: PYTEST_ADDOPTS: "--color=yes" run: poetry run pytest - name: Static type check run: poetry run mypy - name: Upload coverage uses: codecov/codecov-action@v1pathable-0.4.3/.gitignore000066400000000000000000000034071430423130400152640ustar00rootroot00000000000000# Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] *$py.class # C extensions *.so # Distribution / packaging .Python build/ develop-eggs/ dist/ downloads/ eggs/ .eggs/ lib/ lib64/ parts/ sdist/ var/ wheels/ pip-wheel-metadata/ share/python-wheels/ *.egg-info/ .installed.cfg *.egg MANIFEST # PyInstaller # Usually these files are written by a python script from a template # before PyInstaller builds the exe, so as to inject date/other infos into it. *.manifest *.spec # Installer logs pip-log.txt pip-delete-this-directory.txt # Unit test / coverage reports htmlcov/ .tox/ .nox/ .coverage .coverage.* .cache nosetests.xml coverage.xml *.cover *.py,cover .hypothesis/ .pytest_cache/ # Translations *.mo *.pot # Django stuff: *.log local_settings.py db.sqlite3 db.sqlite3-journal # Flask stuff: instance/ .webassets-cache # Scrapy stuff: .scrapy # Sphinx documentation docs/_build/ # PyBuilder target/ # Jupyter Notebook .ipynb_checkpoints # IPython profile_default/ ipython_config.py # pyenv .python-version # pipenv # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. # However, in case of collaboration, if having platform-specific dependencies or dependencies # having no cross-platform support, pipenv may install dependencies that don't work, or not # install all needed dependencies. #Pipfile.lock # PEP 582; used by e.g. github.com/David-OConnor/pyflow __pypackages__/ # Celery stuff celerybeat-schedule celerybeat.pid # SageMath parsed files *.sage.py # Environments .env .venv env/ venv/ ENV/ env.bak/ venv.bak/ # Spyder project settings .spyderproject .spyproject # Rope project settings .ropeproject # mkdocs documentation /site # mypy .mypy_cache/ .dmypy.json dmypy.json # Pyre type checker .pyre/ pathable-0.4.3/.pre-commit-config.yaml000066400000000000000000000017411430423130400175540ustar00rootroot00000000000000--- default_stages: [commit, push] default_language_version: # force all unspecified python hooks to run python3 python: python3 minimum_pre_commit_version: "1.20.0" repos: - repo: meta hooks: - id: check-hooks-apply - repo: https://github.com/asottile/pyupgrade rev: v2.19.0 hooks: - id: pyupgrade args: ["--py36-plus"] # - repo: https://github.com/pre-commit/mirrors-mypy # rev: v0.971 # hooks: # - id: mypy # args: ["pathable"] - repo: local hooks: - id: flynt name: Convert to f-strings with flynt entry: flynt language: python additional_dependencies: ['flynt==0.76'] - id: black name: black entry: black language: system require_serial: true types: [python] - id: isort name: isort entry: isort args: ['--filter-files'] language: system require_serial: true types: [python] pathable-0.4.3/LICENSE000066400000000000000000000261351430423130400143040ustar00rootroot00000000000000 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. pathable-0.4.3/MANIFEST.in000066400000000000000000000000751430423130400150300ustar00rootroot00000000000000include LICENSE include README.rst include pathable/py.typed pathable-0.4.3/README.rst000066400000000000000000000012151430423130400147560ustar00rootroot00000000000000******** pathable ******** About ##### Object-oriented paths Key features ************ * Traverse resources like paths * Access resources on demand with separate accessor layer Usage ##### .. code-block:: python from pathable import DictPath d = { "parts": { "part1": { "name": "Part One", }, "part2": { "name": "Part Two", }, }, } dp = DictPath(d) # Concatenate paths with / parts = dp / "parts" # Stat path keys "part2" in parts # Open path dict with parts.open() as parts_dict: print(parts_dict) pathable-0.4.3/pathable/000077500000000000000000000000001430423130400150505ustar00rootroot00000000000000pathable-0.4.3/pathable/__init__.py000066400000000000000000000010031430423130400171530ustar00rootroot00000000000000"""Pathable module""" from pathable.paths import AccessorPath from pathable.paths import BasePath from pathable.paths import LookupPath from pathable.paths import LookupPath as DictPath from pathable.paths import LookupPath as ListPath __author__ = "Artur Maciag" __email__ = "maciag.artur@gmail.com" __version__ = "0.4.3" __url__ = "https://github.com/p1c2u/pathable" __license__ = "Apache License, Version 2.0" __all__ = [ "BasePath", "AccessorPath", "LookupPath", "DictPath", "ListPath", ] pathable-0.4.3/pathable/accessors.py000066400000000000000000000027641430423130400174200ustar00rootroot00000000000000"""Pathable accessors module""" from contextlib import contextmanager from typing import Any from typing import Dict from typing import Hashable from typing import Iterator from typing import List from typing import Mapping from typing import Union class BaseAccessor: """Base accessor.""" def stat(self, parts: List[Hashable]) -> Dict[str, Any]: raise NotImplementedError def keys(self, parts: List[Hashable]) -> Any: raise NotImplementedError def len(self, parts: List[Hashable]) -> int: raise NotImplementedError @contextmanager def open( self, parts: List[Hashable] ) -> Iterator[Union[Mapping[Hashable, Any], Any]]: raise NotImplementedError class LookupAccessor(BaseAccessor): """Accessor for object that supports __getitem__ lookups""" def __init__(self, lookup: Mapping[Hashable, Any]): self.lookup = lookup def stat(self, parts: List[Hashable]) -> Dict[str, Any]: raise NotImplementedError def keys(self, parts: List[Hashable]) -> Any: with self.open(parts) as d: return d.keys() def len(self, parts: List[Hashable]) -> int: with self.open(parts) as d: return len(d) @contextmanager def open( self, parts: List[Hashable] ) -> Iterator[Union[Mapping[Hashable, Any], Any]]: content = self.lookup for part in parts: content = content[part] try: yield content finally: pass pathable-0.4.3/pathable/dataclasses.py000066400000000000000000000002451430423130400177120ustar00rootroot00000000000000from dataclasses import dataclass from typing import Hashable from typing import List @dataclass class BasePathData: parts: List[Hashable] separator: str pathable-0.4.3/pathable/parsers.py000066400000000000000000000027221430423130400171040ustar00rootroot00000000000000"""Pathable parsers module""" from typing import Any from typing import Hashable from typing import List from typing import Union from pathable.types import PartType SEPARATOR = "/" def parse_parts(parts: List[PartType], sep: str = SEPARATOR) -> List[Hashable]: """Parse (filter and split) path parts.""" parsed: List[Hashable] = [] it = reversed(parts) for part in it: if isinstance(part, int): parsed.append(part) continue if not part: continue if sep in part: for x in reversed(part.split(sep)): if x and x != ".": parsed.append(x) else: if part and part != ".": parsed.append(part) parsed.reverse() return parsed def parse_args(args: List[Any], sep: str = SEPARATOR) -> List[Hashable]: """Canonicalize path constructor arguments.""" parts: List[PartType] = [] for a in args: if hasattr(a, "parts"): parts += a.parts else: if isinstance(a, bytes): a = a.decode("ascii") if isinstance(a, str): parts.append(a) elif isinstance(a, int): parts.append(a) else: raise TypeError( "argument should be a text object or a Path " "object returning text, binary not %r" % type(a) ) return parse_parts(parts, sep) pathable-0.4.3/pathable/paths.py000066400000000000000000000165461430423130400165550ustar00rootroot00000000000000"""Pathable paths module""" from contextlib import contextmanager from typing import Any from typing import Hashable from typing import Iterator from typing import List from typing import Mapping from typing import Optional from typing import Tuple from typing import Type from typing import TypeVar from pathable.accessors import BaseAccessor from pathable.accessors import LookupAccessor from pathable.dataclasses import BasePathData from pathable.parsers import SEPARATOR from pathable.parsers import parse_args TBasePath = TypeVar("TBasePath", bound="BasePath") TAccessorPath = TypeVar("TAccessorPath", bound="AccessorPath") TLookupPath = TypeVar("TLookupPath", bound="LookupPath") class BasePath(BasePathData): """Base path.""" def __init__(self, *args: Any, **kwargs: Any): separator = kwargs.pop("separator", SEPARATOR) self.parts = parse_args(list(args)) self.separator = separator self._cparts_cached: Optional[List[str]] = None @classmethod def _from_parts( cls: Type[TBasePath], args: List[Any], separator: str = SEPARATOR ) -> TBasePath: self = cls(separator=separator) self.parts = parse_args(args) return self @classmethod def _from_parsed_parts( cls: Type[TBasePath], parts: List[Hashable], separator: str = SEPARATOR ) -> TBasePath: self = cls(separator=separator) self.parts = parts return self @property def _cparts(self) -> List[Any]: # Cached casefolded parts, for hashing and comparison if self._cparts_cached is None: self._cparts_cached = self._get_cparts() return self._cparts_cached def _get_cparts(self) -> List[str]: return [str(p) for p in self.parts] def _make_child(self: TBasePath, args: List[Any]) -> TBasePath: parts = parse_args(args, self.separator) parts_joined = self.parts + parts return self._from_parsed_parts(parts_joined, self.separator) def _make_child_relpath(self: TBasePath, part: Hashable) -> TBasePath: # This is an optimization used for dir walking. `part` must be # a single part relative to this path. parts = self.parts + [part] return self._from_parsed_parts(parts, self.separator) def __str__(self) -> str: return self.separator.join(self._cparts) def __repr__(self) -> str: return f"{self.__class__.__name__}({str(self)!r})" def __hash__(self) -> int: return hash(tuple(self._cparts)) def __truediv__(self: TBasePath, key: Any) -> TBasePath: try: return self._make_child( [ key, ] ) except TypeError: return NotImplemented def __rtruediv__(self: TBasePath, key: Hashable) -> TBasePath: try: return self._from_parts([key] + self.parts) except TypeError: return NotImplemented def __eq__(self, other: Any) -> bool: if not isinstance(other, BasePath): return NotImplemented return self._cparts == other._cparts def __lt__(self, other: Any) -> bool: if not isinstance(other, BasePath): return NotImplemented return self._cparts < other._cparts def __le__(self, other: Any) -> bool: if not isinstance(other, BasePath): return NotImplemented return self._cparts <= other._cparts def __gt__(self, other: Any) -> bool: if not isinstance(other, BasePath): return NotImplemented return self._cparts > other._cparts def __ge__(self, other: Any) -> bool: if not isinstance(other, BasePath): return NotImplemented return self._cparts >= other._cparts class AccessorPath(BasePath): """Path for object that can be read by accessor.""" def __init__(self, accessor: BaseAccessor, *args: Any, **kwargs: Any): separator = kwargs.pop("separator", SEPARATOR) super().__init__(*args, separator=separator) self.accessor = accessor self._content_cached: Optional[Any] = None @classmethod def _from_parsed_parts( # type: ignore cls: Type[TAccessorPath], accessor: BaseAccessor, parts: List[Hashable], separator: str = SEPARATOR, ) -> TAccessorPath: self = cls(accessor, separator=separator) self.parts = parts return self def _make_child(self: TAccessorPath, args: List[Any]) -> TAccessorPath: parts = parse_args(args, self.separator) parts_joined = self.parts + parts return self._from_parsed_parts( self.accessor, parts_joined, self.separator ) def _make_child_relpath( self: TAccessorPath, part: Hashable ) -> TAccessorPath: # This is an optimization used for dir walking. `part` must be # a single part relative to this path. parts = self.parts + [part] return self._from_parsed_parts(self.accessor, parts, self.separator) def __iter__(self: TAccessorPath) -> Iterator[TAccessorPath]: return self.iter() def __getitem__(self, key: Hashable) -> Any: with self.open() as d: return d[key] def __contains__(self, key: Hashable) -> bool: with self.open() as d: return key in d def __len__(self) -> int: return self.accessor.len(self.parts) def keys(self) -> Any: return self.accessor.keys(self.parts) def getkey(self, key: Hashable, default: Any = None) -> Any: """Return the value for key if key is in the path, else default.""" with self.open() as d: try: return d[key] except KeyError: return default @contextmanager def open(self) -> Any: """Open the path.""" # Cached path content if self._content_cached is None: with self._open() as content: self._content_cached = content yield self._content_cached else: yield self._content_cached def _open(self) -> Any: return self.accessor.open(self.parts) def iter(self: TAccessorPath) -> Iterator[TAccessorPath]: """Iterate over all child paths.""" for idx in range(self.accessor.len(self.parts)): yield self._make_child_relpath(idx) def iteritems(self: TAccessorPath) -> Iterator[Tuple[Any, TAccessorPath]]: """Return path's items.""" return self.items() def items(self: TAccessorPath) -> Iterator[Tuple[Any, TAccessorPath]]: """Return path's items.""" for key in self.accessor.keys(self.parts): yield key, self._make_child_relpath(key) def content(self) -> Any: """Return content of the path.""" with self.open() as d: return d def get(self, key: Hashable, default: Any = None) -> Any: """Return the child path for key if key is in the path, else default.""" if key in self: return self.__truediv__(key) return default class LookupPath(AccessorPath): """Path for object that supports __getitem__ lookups.""" @classmethod def _from_lookup( cls: Type[TLookupPath], lookup: Mapping[Hashable, Any], *args: Any, **kwargs: Any, ) -> TLookupPath: accessor = LookupAccessor(lookup) return cls(accessor, *args, **kwargs) pathable-0.4.3/pathable/py.typed000066400000000000000000000000001430423130400165350ustar00rootroot00000000000000pathable-0.4.3/pathable/types.py000066400000000000000000000001211430423130400165600ustar00rootroot00000000000000"""Pathable types module""" from typing import Union PartType = Union[str, int] pathable-0.4.3/poetry.lock000066400000000000000000000630331430423130400154710ustar00rootroot00000000000000[[package]] name = "astor" version = "0.8.1" description = "Read/rewrite/write Python ASTs" category = "dev" optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,>=2.7" [[package]] name = "atomicwrites" version = "1.4.0" description = "Atomic file writes." category = "dev" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" [[package]] name = "attrs" version = "21.4.0" description = "Classes Without Boilerplate" category = "dev" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" [package.extras] dev = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "mypy", "pytest-mypy-plugins", "zope.interface", "furo", "sphinx", "sphinx-notfound-page", "pre-commit", "cloudpickle"] docs = ["furo", "sphinx", "zope.interface", "sphinx-notfound-page"] tests = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "mypy", "pytest-mypy-plugins", "zope.interface", "cloudpickle"] tests_no_zope = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "mypy", "pytest-mypy-plugins", "cloudpickle"] [[package]] name = "black" version = "22.1.0" description = "The uncompromising code formatter." category = "dev" optional = false python-versions = ">=3.6.2" [package.dependencies] click = ">=8.0.0" mypy-extensions = ">=0.4.3" pathspec = ">=0.9.0" platformdirs = ">=2" tomli = ">=1.1.0" typed-ast = {version = ">=1.4.2", markers = "python_version < \"3.8\" and implementation_name == \"cpython\""} typing-extensions = {version = ">=3.10.0.0", markers = "python_version < \"3.10\""} [package.extras] colorama = ["colorama (>=0.4.3)"] d = ["aiohttp (>=3.7.4)"] jupyter = ["ipython (>=7.8.0)", "tokenize-rt (>=3.2.0)"] uvloop = ["uvloop (>=0.15.2)"] [[package]] name = "cfgv" version = "3.3.1" description = "Validate configuration and produce human readable error messages." category = "dev" optional = true python-versions = ">=3.6.1" [[package]] name = "click" version = "8.0.3" description = "Composable command line interface toolkit" category = "dev" optional = false python-versions = ">=3.6" [package.dependencies] colorama = {version = "*", markers = "platform_system == \"Windows\""} importlib-metadata = {version = "*", markers = "python_version < \"3.8\""} [[package]] name = "colorama" version = "0.4.4" description = "Cross-platform colored terminal text." category = "dev" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" [[package]] name = "coverage" version = "6.4.4" description = "Code coverage measurement for Python" category = "dev" optional = false python-versions = ">=3.7" [package.dependencies] tomli = {version = "*", optional = true, markers = "python_full_version <= \"3.11.0a6\" and extra == \"toml\""} [package.extras] toml = ["tomli"] [[package]] name = "distlib" version = "0.3.4" description = "Distribution utilities" category = "dev" optional = true python-versions = "*" [[package]] name = "filelock" version = "3.4.2" description = "A platform independent file lock." category = "dev" optional = true python-versions = ">=3.7" [package.extras] docs = ["furo (>=2021.8.17b43)", "sphinx (>=4.1)", "sphinx-autodoc-typehints (>=1.12)"] testing = ["covdefaults (>=1.2.0)", "coverage (>=4)", "pytest (>=4)", "pytest-cov", "pytest-timeout (>=1.4.2)"] [[package]] name = "flake8" version = "4.0.1" description = "the modular source code checker: pep8 pyflakes and co" category = "dev" optional = false python-versions = ">=3.6" [package.dependencies] importlib-metadata = {version = "<4.3", markers = "python_version < \"3.8\""} mccabe = ">=0.6.0,<0.7.0" pycodestyle = ">=2.8.0,<2.9.0" pyflakes = ">=2.4.0,<2.5.0" [[package]] name = "flynt" version = "0.76" description = "CLI tool to convert a python project's %-formatted strings to f-strings." category = "dev" optional = false python-versions = ">=3.6" [package.dependencies] astor = "*" tomli = ">=1.1.0" [[package]] name = "identify" version = "2.4.7" description = "File identification library for Python" category = "dev" optional = true python-versions = ">=3.7" [package.extras] license = ["ukkonen"] [[package]] name = "importlib-metadata" version = "4.2.0" description = "Read metadata from Python packages" category = "dev" optional = false python-versions = ">=3.6" [package.dependencies] typing-extensions = {version = ">=3.6.4", markers = "python_version < \"3.8\""} zipp = ">=0.5" [package.extras] docs = ["sphinx", "jaraco.packaging (>=8.2)", "rst.linker (>=1.9)"] testing = ["pytest (>=4.6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytest-cov", "pytest-enabler (>=1.0.1)", "packaging", "pep517", "pyfakefs", "flufl.flake8", "pytest-black (>=0.3.7)", "pytest-mypy", "importlib-resources (>=1.3)"] [[package]] name = "iniconfig" version = "1.1.1" description = "iniconfig: brain-dead simple config-ini parsing" category = "dev" optional = false python-versions = "*" [[package]] name = "isort" version = "5.10.1" description = "A Python utility / library to sort Python imports." category = "dev" optional = false python-versions = ">=3.6.1,<4.0" [package.extras] pipfile_deprecated_finder = ["pipreqs", "requirementslib"] requirements_deprecated_finder = ["pipreqs", "pip-api"] colors = ["colorama (>=0.4.3,<0.5.0)"] plugins = ["setuptools"] [[package]] name = "mccabe" version = "0.6.1" description = "McCabe checker, plugin for flake8" category = "dev" optional = false python-versions = "*" [[package]] name = "mypy" version = "0.971" description = "Optional static typing for Python" category = "dev" optional = false python-versions = ">=3.6" [package.dependencies] mypy-extensions = ">=0.4.3" tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} typed-ast = {version = ">=1.4.0,<2", markers = "python_version < \"3.8\""} typing-extensions = ">=3.10" [package.extras] dmypy = ["psutil (>=4.0)"] python2 = ["typed-ast (>=1.4.0,<2)"] reports = ["lxml"] [[package]] name = "mypy-extensions" version = "0.4.3" description = "Experimental type system extensions for programs checked with the mypy typechecker." category = "dev" optional = false python-versions = "*" [[package]] name = "nodeenv" version = "1.6.0" description = "Node.js virtual environment builder" category = "dev" optional = true python-versions = "*" [[package]] name = "packaging" version = "21.3" description = "Core utilities for Python packages" category = "dev" optional = false python-versions = ">=3.6" [package.dependencies] pyparsing = ">=2.0.2,<3.0.5 || >3.0.5" [[package]] name = "pathspec" version = "0.9.0" description = "Utility library for gitignore style pattern matching of file paths." category = "dev" optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7" [[package]] name = "platformdirs" version = "2.4.1" description = "A small Python module for determining appropriate platform-specific dirs, e.g. a \"user data dir\"." category = "dev" optional = false python-versions = ">=3.7" [package.extras] docs = ["Sphinx (>=4)", "furo (>=2021.7.5b38)", "proselint (>=0.10.2)", "sphinx-autodoc-typehints (>=1.12)"] test = ["appdirs (==1.4.4)", "pytest (>=6)", "pytest-cov (>=2.7)", "pytest-mock (>=3.6)"] [[package]] name = "pluggy" version = "1.0.0" description = "plugin and hook calling mechanisms for python" category = "dev" optional = false python-versions = ">=3.6" [package.dependencies] importlib-metadata = {version = ">=0.12", markers = "python_version < \"3.8\""} [package.extras] dev = ["pre-commit", "tox"] testing = ["pytest", "pytest-benchmark"] [[package]] name = "pre-commit" version = "2.17.0" description = "A framework for managing and maintaining multi-language pre-commit hooks." category = "dev" optional = true python-versions = ">=3.6.1" [package.dependencies] cfgv = ">=2.0.0" identify = ">=1.0.0" importlib-metadata = {version = "*", markers = "python_version < \"3.8\""} nodeenv = ">=0.11.1" pyyaml = ">=5.1" toml = "*" virtualenv = ">=20.0.8" [[package]] name = "py" version = "1.11.0" description = "library with cross-python path, ini-parsing, io, code, log facilities" category = "dev" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" [[package]] name = "pycodestyle" version = "2.8.0" description = "Python style guide checker" category = "dev" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" [[package]] name = "pyflakes" version = "2.4.0" description = "passive checker of Python programs" category = "dev" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" [[package]] name = "pyparsing" version = "3.0.7" description = "Python parsing module" category = "dev" optional = false python-versions = ">=3.6" [package.extras] diagrams = ["jinja2", "railroad-diagrams"] [[package]] name = "pytest" version = "6.2.5" description = "pytest: simple powerful testing with Python" category = "dev" optional = false python-versions = ">=3.6" [package.dependencies] atomicwrites = {version = ">=1.0", markers = "sys_platform == \"win32\""} attrs = ">=19.2.0" colorama = {version = "*", markers = "sys_platform == \"win32\""} importlib-metadata = {version = ">=0.12", markers = "python_version < \"3.8\""} iniconfig = "*" packaging = "*" pluggy = ">=0.12,<2.0" py = ">=1.8.2" toml = "*" [package.extras] testing = ["argcomplete", "hypothesis (>=3.56)", "mock", "nose", "requests", "xmlschema"] [[package]] name = "pytest-cov" version = "3.0.0" description = "Pytest plugin for measuring coverage." category = "dev" optional = false python-versions = ">=3.6" [package.dependencies] coverage = {version = ">=5.2.1", extras = ["toml"]} pytest = ">=4.6" [package.extras] testing = ["fields", "hunter", "process-tests", "six", "pytest-xdist", "virtualenv"] [[package]] name = "pytest-flake8" version = "1.0.7" description = "pytest plugin to check FLAKE8 requirements" category = "dev" optional = false python-versions = "*" [package.dependencies] flake8 = ">=3.5" pytest = ">=3.5" [[package]] name = "pyyaml" version = "6.0" description = "YAML parser and emitter for Python" category = "dev" optional = true python-versions = ">=3.6" [[package]] name = "six" version = "1.16.0" description = "Python 2 and 3 compatibility utilities" category = "dev" optional = true python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*" [[package]] name = "toml" version = "0.10.2" description = "Python Library for Tom's Obvious, Minimal Language" category = "dev" optional = false python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*" [[package]] name = "tomli" version = "2.0.0" description = "A lil' TOML parser" category = "dev" optional = false python-versions = ">=3.7" [[package]] name = "typed-ast" version = "1.5.2" description = "a fork of Python 2 and 3 ast modules with type comment support" category = "dev" optional = false python-versions = ">=3.6" [[package]] name = "typing-extensions" version = "4.0.1" description = "Backported and Experimental Type Hints for Python 3.6+" category = "dev" optional = false python-versions = ">=3.6" [[package]] name = "virtualenv" version = "20.13.0" description = "Virtual Python Environment builder" category = "dev" optional = true python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7" [package.dependencies] distlib = ">=0.3.1,<1" filelock = ">=3.2,<4" importlib-metadata = {version = ">=0.12", markers = "python_version < \"3.8\""} platformdirs = ">=2,<3" six = ">=1.9.0,<2" [package.extras] docs = ["proselint (>=0.10.2)", "sphinx (>=3)", "sphinx-argparse (>=0.2.5)", "sphinx-rtd-theme (>=0.4.3)", "towncrier (>=21.3)"] testing = ["coverage (>=4)", "coverage-enable-subprocess (>=1)", "flaky (>=3)", "pytest (>=4)", "pytest-env (>=0.6.2)", "pytest-freezegun (>=0.4.1)", "pytest-mock (>=2)", "pytest-randomly (>=1)", "pytest-timeout (>=1)", "packaging (>=20.0)"] [[package]] name = "zipp" version = "3.7.0" description = "Backport of pathlib-compatible object wrapper for zip files" category = "dev" optional = false python-versions = ">=3.7" [package.extras] docs = ["sphinx", "jaraco.packaging (>=8.2)", "rst.linker (>=1.9)"] testing = ["pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytest-cov", "pytest-enabler (>=1.0.1)", "jaraco.itertools", "func-timeout", "pytest-black (>=0.3.7)", "pytest-mypy"] [extras] dev = [] [metadata] lock-version = "1.1" python-versions = "^3.7.0" content-hash = "58db7742dbabcedce160c55c9a4d276b14053b7d98661ea6afaaf1e9dcfd68bd" [metadata.files] astor = [] atomicwrites = [ {file = "atomicwrites-1.4.0-py2.py3-none-any.whl", hash = "sha256:6d1784dea7c0c8d4a5172b6c620f40b6e4cbfdf96d783691f2e1302a7b88e197"}, {file = "atomicwrites-1.4.0.tar.gz", hash = "sha256:ae70396ad1a434f9c7046fd2dd196fc04b12f9e91ffb859164193be8b6168a7a"}, ] attrs = [ {file = "attrs-21.4.0-py2.py3-none-any.whl", hash = "sha256:2d27e3784d7a565d36ab851fe94887c5eccd6a463168875832a1be79c82828b4"}, {file = "attrs-21.4.0.tar.gz", hash = "sha256:626ba8234211db98e869df76230a137c4c40a12d72445c45d5f5b716f076e2fd"}, ] black = [] cfgv = [ {file = "cfgv-3.3.1-py2.py3-none-any.whl", hash = "sha256:c6a0883f3917a037485059700b9e75da2464e6c27051014ad85ba6aaa5884426"}, {file = "cfgv-3.3.1.tar.gz", hash = "sha256:f5a830efb9ce7a445376bb66ec94c638a9787422f96264c98edc6bdeed8ab736"}, ] click = [] colorama = [ {file = "colorama-0.4.4-py2.py3-none-any.whl", hash = "sha256:9f47eda37229f68eee03b24b9748937c7dc3868f906e8ba69fbcbdd3bc5dc3e2"}, {file = "colorama-0.4.4.tar.gz", hash = "sha256:5941b2b48a20143d2267e95b1c2a7603ce057ee39fd88e7329b0c292aa16869b"}, ] coverage = [] distlib = [ {file = "distlib-0.3.4-py2.py3-none-any.whl", hash = "sha256:6564fe0a8f51e734df6333d08b8b94d4ea8ee6b99b5ed50613f731fd4089f34b"}, {file = "distlib-0.3.4.zip", hash = "sha256:e4b58818180336dc9c529bfb9a0b58728ffc09ad92027a3f30b7cd91e3458579"}, ] filelock = [ {file = "filelock-3.4.2-py3-none-any.whl", hash = "sha256:cf0fc6a2f8d26bd900f19bf33915ca70ba4dd8c56903eeb14e1e7a2fd7590146"}, {file = "filelock-3.4.2.tar.gz", hash = "sha256:38b4f4c989f9d06d44524df1b24bd19e167d851f19b50bf3e3559952dddc5b80"}, ] flake8 = [ {file = "flake8-4.0.1-py2.py3-none-any.whl", hash = "sha256:479b1304f72536a55948cb40a32dce8bb0ffe3501e26eaf292c7e60eb5e0428d"}, {file = "flake8-4.0.1.tar.gz", hash = "sha256:806e034dda44114815e23c16ef92f95c91e4c71100ff52813adf7132a6ad870d"}, ] flynt = [] identify = [] importlib-metadata = [ {file = "importlib_metadata-4.2.0-py3-none-any.whl", hash = "sha256:057e92c15bc8d9e8109738a48db0ccb31b4d9d5cfbee5a8670879a30be66304b"}, {file = "importlib_metadata-4.2.0.tar.gz", hash = "sha256:b7e52a1f8dec14a75ea73e0891f3060099ca1d8e6a462a4dff11c3e119ea1b31"}, ] iniconfig = [ {file = "iniconfig-1.1.1-py2.py3-none-any.whl", hash = "sha256:011e24c64b7f47f6ebd835bb12a743f2fbe9a26d4cecaa7f53bc4f35ee9da8b3"}, {file = "iniconfig-1.1.1.tar.gz", hash = "sha256:bc3af051d7d14b2ee5ef9969666def0cd1a000e121eaea580d4a313df4b37f32"}, ] isort = [ {file = "isort-5.10.1-py3-none-any.whl", hash = "sha256:6f62d78e2f89b4500b080fe3a81690850cd254227f27f75c3a0c491a1f351ba7"}, {file = "isort-5.10.1.tar.gz", hash = "sha256:e8443a5e7a020e9d7f97f1d7d9cd17c88bcb3bc7e218bf9cf5095fe550be2951"}, ] mccabe = [ {file = "mccabe-0.6.1-py2.py3-none-any.whl", hash = "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42"}, {file = "mccabe-0.6.1.tar.gz", hash = "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f"}, ] mypy = [] mypy-extensions = [ {file = "mypy_extensions-0.4.3-py2.py3-none-any.whl", hash = "sha256:090fedd75945a69ae91ce1303b5824f428daf5a028d2f6ab8a299250a846f15d"}, {file = "mypy_extensions-0.4.3.tar.gz", hash = "sha256:2d82818f5bb3e369420cb3c4060a7970edba416647068eb4c5343488a6c604a8"}, ] nodeenv = [ {file = "nodeenv-1.6.0-py2.py3-none-any.whl", hash = "sha256:621e6b7076565ddcacd2db0294c0381e01fd28945ab36bcf00f41c5daf63bef7"}, {file = "nodeenv-1.6.0.tar.gz", hash = "sha256:3ef13ff90291ba2a4a7a4ff9a979b63ffdd00a464dbe04acf0ea6471517a4c2b"}, ] packaging = [ {file = "packaging-21.3-py3-none-any.whl", hash = "sha256:ef103e05f519cdc783ae24ea4e2e0f508a9c99b2d4969652eed6a2e1ea5bd522"}, {file = "packaging-21.3.tar.gz", hash = "sha256:dd47c42927d89ab911e606518907cc2d3a1f38bbd026385970643f9c5b8ecfeb"}, ] pathspec = [ {file = "pathspec-0.9.0-py2.py3-none-any.whl", hash = "sha256:7d15c4ddb0b5c802d161efc417ec1a2558ea2653c2e8ad9c19098201dc1c993a"}, {file = "pathspec-0.9.0.tar.gz", hash = "sha256:e564499435a2673d586f6b2130bb5b95f04a3ba06f81b8f895b651a3c76aabb1"}, ] platformdirs = [ {file = "platformdirs-2.4.1-py3-none-any.whl", hash = "sha256:1d7385c7db91728b83efd0ca99a5afb296cab9d0ed8313a45ed8ba17967ecfca"}, {file = "platformdirs-2.4.1.tar.gz", hash = "sha256:440633ddfebcc36264232365d7840a970e75e1018d15b4327d11f91909045fda"}, ] pluggy = [ {file = "pluggy-1.0.0-py2.py3-none-any.whl", hash = "sha256:74134bbf457f031a36d68416e1509f34bd5ccc019f0bcc952c7b909d06b37bd3"}, {file = "pluggy-1.0.0.tar.gz", hash = "sha256:4224373bacce55f955a878bf9cfa763c1e360858e330072059e10bad68531159"}, ] pre-commit = [ {file = "pre_commit-2.17.0-py2.py3-none-any.whl", hash = "sha256:725fa7459782d7bec5ead072810e47351de01709be838c2ce1726b9591dad616"}, {file = "pre_commit-2.17.0.tar.gz", hash = "sha256:c1a8040ff15ad3d648c70cc3e55b93e4d2d5b687320955505587fd79bbaed06a"}, ] py = [ {file = "py-1.11.0-py2.py3-none-any.whl", hash = "sha256:607c53218732647dff4acdfcd50cb62615cedf612e72d1724fb1a0cc6405b378"}, {file = "py-1.11.0.tar.gz", hash = "sha256:51c75c4126074b472f746a24399ad32f6053d1b34b68d2fa41e558e6f4a98719"}, ] pycodestyle = [ {file = "pycodestyle-2.8.0-py2.py3-none-any.whl", hash = "sha256:720f8b39dde8b293825e7ff02c475f3077124006db4f440dcbc9a20b76548a20"}, {file = "pycodestyle-2.8.0.tar.gz", hash = "sha256:eddd5847ef438ea1c7870ca7eb78a9d47ce0cdb4851a5523949f2601d0cbbe7f"}, ] pyflakes = [ {file = "pyflakes-2.4.0-py2.py3-none-any.whl", hash = "sha256:3bb3a3f256f4b7968c9c788781e4ff07dce46bdf12339dcda61053375426ee2e"}, {file = "pyflakes-2.4.0.tar.gz", hash = "sha256:05a85c2872edf37a4ed30b0cce2f6093e1d0581f8c19d7393122da7e25b2b24c"}, ] pyparsing = [ {file = "pyparsing-3.0.7-py3-none-any.whl", hash = "sha256:a6c06a88f252e6c322f65faf8f418b16213b51bdfaece0524c1c1bc30c63c484"}, {file = "pyparsing-3.0.7.tar.gz", hash = "sha256:18ee9022775d270c55187733956460083db60b37d0d0fb357445f3094eed3eea"}, ] pytest = [ {file = "pytest-6.2.5-py3-none-any.whl", hash = "sha256:7310f8d27bc79ced999e760ca304d69f6ba6c6649c0b60fb0e04a4a77cacc134"}, {file = "pytest-6.2.5.tar.gz", hash = "sha256:131b36680866a76e6781d13f101efb86cf674ebb9762eb70d3082b6f29889e89"}, ] pytest-cov = [ {file = "pytest-cov-3.0.0.tar.gz", hash = "sha256:e7f0f5b1617d2210a2cabc266dfe2f4c75a8d32fb89eafb7ad9d06f6d076d470"}, {file = "pytest_cov-3.0.0-py3-none-any.whl", hash = "sha256:578d5d15ac4a25e5f961c938b85a05b09fdaae9deef3bb6de9a6e766622ca7a6"}, ] pytest-flake8 = [ {file = "pytest-flake8-1.0.7.tar.gz", hash = "sha256:f0259761a903563f33d6f099914afef339c085085e643bee8343eb323b32dd6b"}, {file = "pytest_flake8-1.0.7-py2.py3-none-any.whl", hash = "sha256:c28cf23e7d359753c896745fd4ba859495d02e16c84bac36caa8b1eec58f5bc1"}, ] pyyaml = [ {file = "PyYAML-6.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:d4db7c7aef085872ef65a8fd7d6d09a14ae91f691dec3e87ee5ee0539d516f53"}, {file = "PyYAML-6.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:9df7ed3b3d2e0ecfe09e14741b857df43adb5a3ddadc919a2d94fbdf78fea53c"}, {file = "PyYAML-6.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:77f396e6ef4c73fdc33a9157446466f1cff553d979bd00ecb64385760c6babdc"}, {file = "PyYAML-6.0-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:a80a78046a72361de73f8f395f1f1e49f956c6be882eed58505a15f3e430962b"}, {file = "PyYAML-6.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:f84fbc98b019fef2ee9a1cb3ce93e3187a6df0b2538a651bfb890254ba9f90b5"}, {file = "PyYAML-6.0-cp310-cp310-win32.whl", hash = "sha256:2cd5df3de48857ed0544b34e2d40e9fac445930039f3cfe4bcc592a1f836d513"}, {file = "PyYAML-6.0-cp310-cp310-win_amd64.whl", hash = "sha256:daf496c58a8c52083df09b80c860005194014c3698698d1a57cbcfa182142a3a"}, {file = "PyYAML-6.0-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:897b80890765f037df3403d22bab41627ca8811ae55e9a722fd0392850ec4d86"}, {file = "PyYAML-6.0-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:50602afada6d6cbfad699b0c7bb50d5ccffa7e46a3d738092afddc1f9758427f"}, {file = "PyYAML-6.0-cp36-cp36m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:48c346915c114f5fdb3ead70312bd042a953a8ce5c7106d5bfb1a5254e47da92"}, {file = "PyYAML-6.0-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:98c4d36e99714e55cfbaaee6dd5badbc9a1ec339ebfc3b1f52e293aee6bb71a4"}, {file = "PyYAML-6.0-cp36-cp36m-win32.whl", hash = "sha256:0283c35a6a9fbf047493e3a0ce8d79ef5030852c51e9d911a27badfde0605293"}, {file = "PyYAML-6.0-cp36-cp36m-win_amd64.whl", hash = "sha256:07751360502caac1c067a8132d150cf3d61339af5691fe9e87803040dbc5db57"}, {file = "PyYAML-6.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:819b3830a1543db06c4d4b865e70ded25be52a2e0631ccd2f6a47a2822f2fd7c"}, {file = "PyYAML-6.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:473f9edb243cb1935ab5a084eb238d842fb8f404ed2193a915d1784b5a6b5fc0"}, {file = "PyYAML-6.0-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:0ce82d761c532fe4ec3f87fc45688bdd3a4c1dc5e0b4a19814b9009a29baefd4"}, {file = "PyYAML-6.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:231710d57adfd809ef5d34183b8ed1eeae3f76459c18fb4a0b373ad56bedcdd9"}, {file = "PyYAML-6.0-cp37-cp37m-win32.whl", hash = "sha256:c5687b8d43cf58545ade1fe3e055f70eac7a5a1a0bf42824308d868289a95737"}, {file = "PyYAML-6.0-cp37-cp37m-win_amd64.whl", hash = "sha256:d15a181d1ecd0d4270dc32edb46f7cb7733c7c508857278d3d378d14d606db2d"}, {file = "PyYAML-6.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:0b4624f379dab24d3725ffde76559cff63d9ec94e1736b556dacdfebe5ab6d4b"}, {file = "PyYAML-6.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:213c60cd50106436cc818accf5baa1aba61c0189ff610f64f4a3e8c6726218ba"}, {file = "PyYAML-6.0-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:9fa600030013c4de8165339db93d182b9431076eb98eb40ee068700c9c813e34"}, {file = "PyYAML-6.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:277a0ef2981ca40581a47093e9e2d13b3f1fbbeffae064c1d21bfceba2030287"}, {file = "PyYAML-6.0-cp38-cp38-win32.whl", hash = "sha256:d4eccecf9adf6fbcc6861a38015c2a64f38b9d94838ac1810a9023a0609e1b78"}, {file = "PyYAML-6.0-cp38-cp38-win_amd64.whl", hash = "sha256:1e4747bc279b4f613a09eb64bba2ba602d8a6664c6ce6396a4d0cd413a50ce07"}, {file = "PyYAML-6.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:055d937d65826939cb044fc8c9b08889e8c743fdc6a32b33e2390f66013e449b"}, {file = "PyYAML-6.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:e61ceaab6f49fb8bdfaa0f92c4b57bcfbea54c09277b1b4f7ac376bfb7a7c174"}, {file = "PyYAML-6.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d67d839ede4ed1b28a4e8909735fc992a923cdb84e618544973d7dfc71540803"}, {file = "PyYAML-6.0-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:cba8c411ef271aa037d7357a2bc8f9ee8b58b9965831d9e51baf703280dc73d3"}, {file = "PyYAML-6.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:40527857252b61eacd1d9af500c3337ba8deb8fc298940291486c465c8b46ec0"}, {file = "PyYAML-6.0-cp39-cp39-win32.whl", hash = "sha256:b5b9eccad747aabaaffbc6064800670f0c297e52c12754eb1d976c57e4f74dcb"}, {file = "PyYAML-6.0-cp39-cp39-win_amd64.whl", hash = "sha256:b3d267842bf12586ba6c734f89d1f5b871df0273157918b0ccefa29deb05c21c"}, {file = "PyYAML-6.0.tar.gz", hash = "sha256:68fb519c14306fec9720a2a5b45bc9f0c8d1b9c72adf45c37baedfcd949c35a2"}, ] six = [ {file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"}, {file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"}, ] toml = [ {file = "toml-0.10.2-py2.py3-none-any.whl", hash = "sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b"}, {file = "toml-0.10.2.tar.gz", hash = "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f"}, ] tomli = [ {file = "tomli-2.0.0-py3-none-any.whl", hash = "sha256:b5bde28da1fed24b9bd1d4d2b8cba62300bfb4ec9a6187a957e8ddb9434c5224"}, {file = "tomli-2.0.0.tar.gz", hash = "sha256:c292c34f58502a1eb2bbb9f5bbc9a5ebc37bee10ffb8c2d6bbdfa8eb13cc14e1"}, ] typed-ast = [] typing-extensions = [ {file = "typing_extensions-4.0.1-py3-none-any.whl", hash = "sha256:7f001e5ac290a0c0401508864c7ec868be4e701886d5b573a9528ed3973d9d3b"}, {file = "typing_extensions-4.0.1.tar.gz", hash = "sha256:4ca091dea149f945ec56afb48dae714f21e8692ef22a395223bcd328961b6a0e"}, ] virtualenv = [ {file = "virtualenv-20.13.0-py2.py3-none-any.whl", hash = "sha256:339f16c4a86b44240ba7223d0f93a7887c3ca04b5f9c8129da7958447d079b09"}, {file = "virtualenv-20.13.0.tar.gz", hash = "sha256:d8458cf8d59d0ea495ad9b34c2599487f8a7772d796f9910858376d1600dd2dd"}, ] zipp = [ {file = "zipp-3.7.0-py3-none-any.whl", hash = "sha256:b47250dd24f92b7dd6a0a8fc5244da14608f3ca90a5efcd37a3b1642fac9a375"}, {file = "zipp-3.7.0.tar.gz", hash = "sha256:9f50f446828eb9d45b267433fd3e9da8d801f614129124863f9c51ebceafb87d"}, ] pathable-0.4.3/pyproject.toml000066400000000000000000000041601430423130400162050ustar00rootroot00000000000000[build-system] requires = ["poetry-core>=1.0.0"] build-backend = "poetry.core.masonry.api" [tool.coverage.run] branch = true source =["pathable"] [tool.coverage.xml] output = "reports/coverage.xml" [tool.mypy] files = "pathable" strict = true # files = "pathable" # check_untyped_defs = true # disallow_subclassing_any = true # disallow_untyped_calls = true # disallow_untyped_defs = false # ignore_missing_imports = false # show_column_numbers = true # show_none_errors = true # strict_optional = true # warn_incomplete_stub = true # warn_no_return = true # warn_redundant_casts = true # warn_return_any = true # warn_unused_configs = true # warn_unused_ignores = true # allow_redefinition = true # no_implicit_optional = true # local_partial_types = true # strict_equality = true [tool.poetry] name = "pathable" version = "0.4.3" description = "Object-oriented paths" authors = ["Artur Maciag "] license = "Apache License, Version 2.0" readme = "README.rst" repository = "https://github.com/p1c2u/pathable" keywords = ["dict", "dictionary", "list", "lookup", "path", "pathable"] classifiers = [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "Topic :: Software Development :: Libraries :: Python Modules", "Operating System :: OS Independent", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Topic :: Software Development :: Libraries" ] [tool.poetry.dependencies] python = "^3.7.0" [tool.poetry.extras] dev = ["pre-commit"] [tool.poetry.dev-dependencies] pre-commit = {version = "*", optional = true} pytest = "^6.2.5" pytest-flake8 = "=1.0.7" pytest-cov = "^3.0.0" isort = "^5.0.0" black = "^22.0.0" flynt = "0.76" mypy = "^0.971" [tool.pytest.ini_options] addopts = """ --capture=no --verbose --showlocals --junitxml=reports/junit.xml --cov=pathable --cov-report=term-missing --cov-report=xml """ [tool.black] line-length = 79 [tool.isort] profile = "black" line_length = 79 force_single_line = true pathable-0.4.3/tests/000077500000000000000000000000001430423130400144325ustar00rootroot00000000000000pathable-0.4.3/tests/__init__.py000066400000000000000000000000001430423130400165310ustar00rootroot00000000000000pathable-0.4.3/tests/unit/000077500000000000000000000000001430423130400154115ustar00rootroot00000000000000pathable-0.4.3/tests/unit/__init__.py000066400000000000000000000000001430423130400175100ustar00rootroot00000000000000pathable-0.4.3/tests/unit/test_parsers.py000066400000000000000000000044131430423130400205030ustar00rootroot00000000000000import pytest from pathable.parsers import parse_args from pathable.parsers import parse_parts from pathable.paths import BasePath class TestParseParts: separator = "/" def test_empty(self): parts = [] result = parse_parts(parts, self.separator) assert result == [] def test_one(self): parts = ["test"] result = parse_parts(parts, self.separator) assert result == ["test"] def test_simple(self): parts = ["test", "test1", "test2"] result = parse_parts(parts, self.separator) assert result == ["test", "test1", "test2"] def test_none(self): parts = ["test", None, "test1", None, "test2"] result = parse_parts(parts, self.separator) assert result == ["test", "test1", "test2"] def test_relative(self): parts = ["test", ".", "test1", ".", "test2"] result = parse_parts(parts, self.separator) assert result == ["test", "test1", "test2"] def test_separator(self): sep_part = "test1{sep}test2{sep}test3".format(sep=self.separator) parts = ["test", sep_part] result = parse_parts(parts, self.separator) assert result == ["test", "test1", "test2", "test3"] def test_separator_with_relative(self): sep_part = "test1{sep}.{sep}test2{sep}.{sep}test3".format( sep=self.separator ) parts = ["test", sep_part] result = parse_parts(parts, self.separator) assert result == ["test", "test1", "test2", "test3"] class TestParseArgs: separator = "/" def test_empty(self): args = [] result = parse_args(args, self.separator) assert result == [] def test_string(self): args = ["test"] result = parse_args(args, self.separator) assert result == ["test"] def test_string_many(self): args = ["test", "test2"] result = parse_args(args, self.separator) assert result == ["test", "test2"] def test_path(self): args = [BasePath("test")] result = parse_args(args, self.separator) assert result == ["test"] def test_invalid_part(self): args = [(2,), (3,)] with pytest.raises(TypeError): parse_args(args, self.separator) pathable-0.4.3/tests/unit/test_paths.py000066400000000000000000000471661430423130400201570ustar00rootroot00000000000000from types import GeneratorType import pytest from pathable.parsers import SEPARATOR from pathable.paths import BasePath from pathable.paths import LookupPath class TestBasePathInit: def test_default(self): p = BasePath() assert p.parts == [] assert p.separator == SEPARATOR def test_part_text(self): part = "part" p = BasePath(part) assert p.parts == [ part, ] assert p.separator == SEPARATOR def test_part_binary(self): part = b"part" p = BasePath(part) assert p.parts == [ "part", ] assert p.separator == SEPARATOR def test_part_binary_many(self): part1 = b"part1" part2 = b"part2" p = BasePath(part1, part2) assert p.parts == ["part1", "part2"] assert p.separator == SEPARATOR def test_part_text_many(self): part1 = "part1" part2 = "part2" p = BasePath(part1, part2) assert p.parts == [part1, part2] assert p.separator == SEPARATOR def test_part_path(self): part = "part" p1 = BasePath(part) p = BasePath(p1) assert p.parts == [ part, ] assert p.separator == SEPARATOR def test_part_path_many(self): part1 = "part1" part2 = "part2" p1 = BasePath(part1) p2 = BasePath(part2) p = BasePath(p1, p2) assert p.parts == [part1, part2] assert p.separator == SEPARATOR def test_separator(self): separator = "." p = BasePath(separator=separator) assert p.parts == [] assert p.separator == separator class TestBasePathStr: def test_empty(self): p = BasePath() assert str(p) == "" def test_single(self): p = BasePath("part1") assert str(p) == "part1" def test_double(self): args = ["part1", "part2"] p = BasePath(*args) assert str(p) == SEPARATOR.join(args) def test_separator(self): args = ["part1", "part2"] separator = "," p = BasePath(*args, separator=separator) assert str(p) == separator.join(args) def test_cparts_cached(self): args = ["part1", "part2"] separator = "," p = BasePath(*args, separator=separator) p._cparts_cached = p._get_cparts() assert str(p) == separator.join(args) class TestBasePathRepr: def test_empty(self): p = BasePath() assert repr(p) == "BasePath('')" def test_single(self): arg = "part1" p = BasePath(arg) assert repr(p) == f"BasePath('{arg}')" def test_double(self): args = ["part1", "part2"] p = BasePath(*args) p_str = SEPARATOR.join(args) assert repr(p) == f"BasePath('{p_str}')" def test_separator(self): args = ["part1", "part2"] separator = "," p = BasePath(*args, separator=separator) p_str = separator.join(args) assert repr(p) == f"BasePath('{p_str}')" class TestBasePathHash: def test_empty(self): p = BasePath() assert hash(p) == hash(tuple(p._cparts)) def test_single(self): p = BasePath("part1") assert hash(p) == hash(tuple(p._cparts)) def test_double(self): args = ["part1", "part2"] p = BasePath(*args) assert hash(p) == hash(tuple(p._cparts)) def test_separator(self): args = ["part1", "part2"] separator = "," p = BasePath(*args, separator=separator) assert hash(p) == hash(tuple(p._cparts)) def test_cparts_cached(self): args = ["part1", "part2"] separator = "," p = BasePath(*args, separator=separator) p._cparts_cached = p._get_cparts() assert hash(p) == hash(tuple(p._cparts)) class TestBasePathMakeChild: @pytest.fixture def base_path(self): return BasePath(separator=SEPARATOR) def test_none(self, base_path): args = [] p = base_path._make_child(args) assert p.parts == args assert p.separator == SEPARATOR def test_arg(self, base_path): args = ["part1"] p = base_path._make_child(args) assert p.parts == args assert p.separator == SEPARATOR def test_arg_unparsed(self, base_path): parts = ["part1", "part2"] arg = SEPARATOR.join(parts) args = [arg] p = base_path._make_child(args) assert p.parts == parts assert p.separator == SEPARATOR def test_args_many(self, base_path): args = ["part1", "part2"] p = base_path._make_child(args) assert p.parts == args assert p.separator == SEPARATOR class TestBasePathMakeChildRelPath: @pytest.fixture def base_path(self): return BasePath(separator=SEPARATOR) def test_part(self, base_path): part = "part1" p = base_path._make_child_relpath(part) assert p.parts == [part] assert p.separator == SEPARATOR class TestBasePathTruediv: def test_default_empty(self): p = BasePath() / "" assert p.parts == [] assert p.separator == SEPARATOR @pytest.mark.parametrize( "part1,part2,parts,separator", ( [ "", "", [], SEPARATOR, ], [ "", "part1", ["part1"], SEPARATOR, ], [ "part1", "", ["part1"], SEPARATOR, ], [ "part1", "part2", ["part1", "part2"], SEPARATOR, ], [ b"", "", [], SEPARATOR, ], [ b"", "part1", ["part1"], SEPARATOR, ], [ b"part1", "", ["part1"], SEPARATOR, ], [ b"part1", "part2", ["part1", "part2"], SEPARATOR, ], [ "part1", BasePath("part2"), ["part1", "part2"], SEPARATOR, ], [ BasePath("part1"), "part2", ["part1", "part2"], SEPARATOR, ], [ BasePath("part1"), BasePath("part2"), ["part1", "part2"], SEPARATOR, ], ), ) def test_parts(self, part1, part2, parts, separator): p = BasePath(part1) / part2 assert p.parts == parts assert p.separator == separator def test_combined(self): part11 = "part11" part12 = "part12" part21 = "part21" part22 = "part22" part1 = SEPARATOR.join([part11, part12]) part2 = SEPARATOR.join([part21, part22]) p = BasePath(part1) / part2 assert p.parts == [part11, part12, part21, part22] assert p.separator == SEPARATOR def test_combined_different_separators(self): part11 = "part11" part12 = "part12" part21 = "part21" part22 = "part22" separator1 = "." part1 = SEPARATOR.join([part11, part12]) part2 = SEPARATOR.join([part21, part22]) p1 = BasePath(part2) p = BasePath(part1, separator=separator1) / p1 assert p.parts == [part11, part12, part21, part22] assert p.separator == separator1 def test_type_not_implemented(self): with pytest.raises(TypeError): BasePath() / [] class TestBasePathRtruediv: def test_default_empty(self): p = "" / BasePath() assert p.parts == [] assert p.separator == SEPARATOR @pytest.mark.parametrize( "part1,part2,parts,separator", ( [ "", "", [], SEPARATOR, ], [ "", "part1", ["part1"], SEPARATOR, ], [ "part1", "", ["part1"], SEPARATOR, ], [ "part1", "part2", ["part1", "part2"], SEPARATOR, ], [ b"", "", [], SEPARATOR, ], [ b"", "part1", ["part1"], SEPARATOR, ], [ b"part1", "", ["part1"], SEPARATOR, ], [ b"part1", "part2", ["part1", "part2"], SEPARATOR, ], [ "part1", BasePath("part2"), ["part1", "part2"], SEPARATOR, ], [ BasePath("part1"), "part2", ["part1", "part2"], SEPARATOR, ], [ BasePath("part1"), BasePath("part2"), ["part1", "part2"], SEPARATOR, ], ), ) def test_parts(self, part1, part2, parts, separator): p = part1 / BasePath(part2) assert p.parts == parts assert p.separator == separator def test_combined(self): part11 = "part11" part12 = "part12" part21 = "part21" part22 = "part22" part1 = SEPARATOR.join([part11, part12]) part2 = SEPARATOR.join([part21, part22]) p = part1 / BasePath(part2) assert p.parts == [part11, part12, part21, part22] assert p.separator == SEPARATOR def test_type_not_implemented(self): with pytest.raises(TypeError): [] / BasePath() class TestBasePathEq: @pytest.mark.parametrize( "part1,part2,expected", ( ["", "", True], ["", "part", False], ["part", "", False], ["part", "part", True], ["part", BasePath("part"), True], [BasePath("part"), "part", True], [BasePath("part"), BasePath("part"), True], ), ) def test_parts(self, part1, part2, expected): result = BasePath(part1) == BasePath(part2) assert result is expected def test_type_not_implemented(self): result = BasePath() == [] assert result is False class TestBasePathLt: @pytest.mark.parametrize( "part1,part2,expected", ( ["", "", False], ["", "part", True], ["part", "", False], ["part", "part", False], ["part", "part2", True], ["part", BasePath("part"), False], ["part", BasePath("part2"), True], [BasePath("part"), "part", False], [BasePath("part"), BasePath("part"), False], [BasePath("part"), BasePath("part2"), True], ), ) def test_parts(self, part1, part2, expected): result = BasePath(part1) < BasePath(part2) assert result is expected def test_type_not_implemented(self): with pytest.raises(TypeError): BasePath() < [] class TestBasePathLe: @pytest.mark.parametrize( "part1,part2,expected", ( ["", "", True], ["", "part", True], ["part", "", False], ["part", "part", True], ["part", "part2", True], ["part", BasePath("part"), True], ["part", BasePath("part2"), True], [BasePath("part"), "part", True], [BasePath("part"), BasePath("part"), True], [BasePath("part"), BasePath("part2"), True], ), ) def test_parts(self, part1, part2, expected): result = BasePath(part1) <= BasePath(part2) assert result is expected def test_type_not_implemented(self): with pytest.raises(TypeError): BasePath() <= [] class TestBasePathGt: @pytest.mark.parametrize( "part1,part2,expected", ( ["", "", False], ["", "part", False], ["part", "", True], ["part", "part", False], ["part", "part2", False], ["part", BasePath("part"), False], ["part", BasePath("part2"), False], [BasePath("part"), "part", False], [BasePath("part"), BasePath("part"), False], [BasePath("part"), BasePath("part2"), False], ), ) def test_parts(self, part1, part2, expected): result = BasePath(part1) > BasePath(part2) assert result is expected def test_type_not_implemented(self): with pytest.raises(TypeError): BasePath() > [] class TestBasePathGe: @pytest.mark.parametrize( "part1,part2,expected", ( ["", "", True], ["", "part", False], ["part", "", True], ["part", "part", True], ["part", "part2", False], ["part", BasePath("part"), True], ["part", BasePath("part2"), False], [BasePath("part"), "part", True], [BasePath("part"), BasePath("part"), True], [BasePath("part"), BasePath("part2"), False], ), ) def test_parts(self, part1, part2, expected): result = BasePath(part1) >= BasePath(part2) assert result is expected def test_type_not_implemented(self): with pytest.raises(TypeError): BasePath() >= [] class TestLookupPathIter: def test_object(self): resource = {"test1": {"test2": {"test3": "test"}}} p = LookupPath._from_lookup(resource, "test1/test2") result = iter(p) assert type(result) == GeneratorType result_list = list(result) assert result_list == [ LookupPath._from_lookup(resource, "test1/test2/0"), ] def test_list(self): resource = {"test1": {"test2": ["test3", "test4"]}} p = LookupPath._from_lookup(resource, "test1/test2") result = iter(p) assert type(result) == GeneratorType result_list = list(result) assert result_list == [ LookupPath._from_lookup(resource, "test1/test2/0"), LookupPath._from_lookup(resource, "test1/test2/1"), ] class TestLookupPathGetItem: def test_valid(self): value = "testvalue" resource = {"test1": {"test2": {"test3": value}}} p = LookupPath._from_lookup(resource, "test1/test2") result = p["test3"] assert result == value def test_invalid(self): value = "testvalue" resource = {"test1": {"test2": {"test3": value}}} p = LookupPath._from_lookup(resource, "test1/test2") with pytest.raises(KeyError): p["test4"] class TestLookupPathGetkey: def test_valid(self): value = "testvalue" resource = {"test1": {"test2": {"test3": value}}} p = LookupPath._from_lookup(resource, "test1/test2") result = p.getkey("test3") assert result == value def test_invalid(self): value = "testvalue" resource = {"test1": {"test2": {"test3": value}}} p = LookupPath._from_lookup(resource, "test1/test2") result = p.getkey("test4") assert result is None class TestLookupPathGet: def test_non_existing_key_default_none(self): value = "testvalue" resource = {"test1": {"test2": {"test3": value}}} p = LookupPath._from_lookup(resource, "test1/test2") result = p.get("") assert result == None def test_non_existing_key_default_defined(self): value = "testvalue" resource = {"test1": {"test2": {"test3": value}}} p = LookupPath._from_lookup(resource, "test1/test2") result = p.get("", default=value) assert result == value @pytest.mark.parametrize( "resource,key,expected", ( [ {"test1": "test2"}, "test1", LookupPath._from_lookup({"test1": "test2"}, "test1"), ], [ {"test1": {"test2": "test3"}}, "test1", LookupPath._from_lookup( {"test1": {"test2": "test3"}}, "test1" ), ], ), ) def test_key_exists(self, resource, key, expected): p = LookupPath._from_lookup(resource) result = p.get(key) assert result == expected class TestLookupPathLen: def test_empty(self): resource = {} p = LookupPath._from_lookup(resource) result = len(p) assert result == 0 def test_value(self): resource = {"test1": "test2"} p = LookupPath._from_lookup(resource, "test1") result = len(p) assert result == 5 def test_single(self): resource = {"test1": "test2"} p = LookupPath._from_lookup(resource) result = len(p) assert result == 1 def test_list(self): resource = {"test1": [{"test2": "test3"}, {"test4": "test5"}]} p = LookupPath._from_lookup(resource, "test1") result = len(p) assert result == 2 class TestLookupPathKeys: def test_empty(self): resource = {} p = LookupPath._from_lookup(resource) result = p.keys() assert list(result) == [] def test_value(self): resource = {"test1": "test2"} p = LookupPath._from_lookup(resource, "test1") with pytest.raises(AttributeError): p.keys() def test_single(self): resource = {"test1": "test2"} p = LookupPath._from_lookup(resource) result = p.keys() assert list(result) == ["test1"] def test_list(self): resource = {"test1": [{"test2": "test3"}, {"test4": "test5"}]} p = LookupPath._from_lookup(resource, "test1") with pytest.raises(AttributeError): p.keys() class TestLookupPathContains: def test_valid(self): value = "testvalue" resource = {"test1": {"test2": {"test3": value}}} p = LookupPath._from_lookup(resource, "test1/test2") result = "test3" in p assert result is True def test_invalid(self): value = "testvalue" resource = {"test1": {"test2": {"test3": value}}} p = LookupPath._from_lookup(resource, "test1/test2") result = "test4" in p assert result is False class TestLookupPathItems: def test_empty(self): resource = {} p = LookupPath._from_lookup(resource) result = p.items() assert type(result) is GeneratorType assert dict(result) == {} def test_keys(self): resource = { "test1": 1, "test2": 2, } p = LookupPath._from_lookup(resource) result = p.items() assert type(result) is GeneratorType assert dict(result) == { "test1": p / "test1", "test2": p / "test2", } class TestLookupPathOpen: def test_content_cached(self): value = { "test3": "test4", } resource = { "test1": 1, "test2": value, } p = LookupPath._from_lookup(resource, "test2") result = p.getkey("test3") assert result == p.getkey("test3") assert p._content_cached == value