From ed80c1f8bdff1c5360ca085ceac79b4d8de041e4 Mon Sep 17 00:00:00 2001
From: bnavigator <>
Date: Dec 22 2021 20:14:53 +0000
Subject: Delete python-requirementslib via SR 941716
https://build.opensuse.org/request/show/941716
by user bnavigator + dimstar_suse
does not build with python310. was required by
* python-passa: removed
* python-isort:test: skip tests, otpional requirementslib only used for deprecated finder.
---
diff --git a/packages/p/python-requirementslib/.files b/packages/p/python-requirementslib/.files
deleted file mode 100644
index 1291000..0000000
Binary files a/packages/p/python-requirementslib/.files and /dev/null differ
diff --git a/packages/p/python-requirementslib/.meta b/packages/p/python-requirementslib/.meta
deleted file mode 100644
index 14b30b5..0000000
--- a/packages/p/python-requirementslib/.meta
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
- A tool for converting between pip-style and pipfile requirements
-
-
diff --git a/packages/p/python-requirementslib/.rev b/packages/p/python-requirementslib/.rev
deleted file mode 100644
index bd01ad2..0000000
--- a/packages/p/python-requirementslib/.rev
+++ /dev/null
@@ -1,105 +0,0 @@
-
-
- 6a341ae8b0c497574c857b15e3953679
- 1.4.2
-
- dimstar_suse
-
- 683546
-
-
- e73d672f0e7aed584e9f7d5de7c3e376
- 1.5.1
-
- dimstar_suse
-
- 709394
-
-
- ee5a622de651893ec18d6df7c8cd0aae
- 1.5.3
-
- dimstar_suse
- - Update to 1.5.3:
- * Added support for parsing lists of variables as extras in setup.py files via ast.BinOp traversal. #177
- * various bugfixes
-
-- Do not depend on pytest-sugar, it is just pretty-formatter
- 719549
-
-
- 3dba57c39be69426a7d29ab2ffd4ee45
- 1.5.3
-
- dimstar_suse
- Py2 fix Staging:I
- 784792
-
-
- f942bae3a46ca4b1134343b16be17672
- 1.5.12
-
- dimstar_suse
-
- 820914
-
-
- 82b48fbd86fe1ccc158662092761b028
- 1.5.12
-
- dimstar_suse
-
- 827758
-
-
- 6d4efb421b0f9abbe73ade85cb3ddaa9
- 1.5.13
-
- dimstar_suse
-
- 842436
-
-
- 45332b4122a1211f403fe1185ea724eb
- 1.5.16
-
- dimstar_suse
-
- 848389
-
-
- 8a68bb4ce1e636a819bad86d921f1675
- 1.5.16
-
- RBrownSUSE
-
- 880620
-
-
- f4f494cf36a00e9eb35aff8eb8a8c2aa
- 1.5.16
-
- dimstar_suse
-
- 928435
-
-
- e5d9e37edb625f7d285dcfe846a82380
- 1.5.16
-
- dimstar_suse
-
- 930577
-
-
- c58cba17c66834d1a28cb9ac69f0b272
- 1.5.16
-
- dimstar_suse
- - Skip failing tests test_parse_function_call_as_name,
- test_repo_line, and test_requirement_line
- (gh#sarugaku/requirementslib#303).
-
- 935085
-
-
diff --git a/packages/p/python-requirementslib/LICENSE.boltons b/packages/p/python-requirementslib/LICENSE.boltons
deleted file mode 100644
index 6a4c9d2..0000000
--- a/packages/p/python-requirementslib/LICENSE.boltons
+++ /dev/null
@@ -1,29 +0,0 @@
-Copyright (c) 2013, Mahmoud Hashemi
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- * 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.
-
- * The names of the contributors may not be used to endorse or
- promote products derived from this software without specific
- prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/packages/p/python-requirementslib/pyinstaller-setup.py b/packages/p/python-requirementslib/pyinstaller-setup.py
deleted file mode 100644
index 157c347..0000000
--- a/packages/p/python-requirementslib/pyinstaller-setup.py
+++ /dev/null
@@ -1,80 +0,0 @@
-#! /usr/bin/env python
-#-----------------------------------------------------------------------------
-# Copyright (c) 2005-2020, PyInstaller Development Team.
-#
-# Distributed under the terms of the GNU General Public License (version 2
-# or later) with exception for distributing the bootloader.
-#
-# The full license is in the file COPYING.txt, distributed with this software.
-#
-# SPDX-License-Identifier: (GPL-2.0-or-later WITH Bootloader-exception)
-#-----------------------------------------------------------------------------
-
-import sys
-import os
-from setuptools import setup
-
-# Hack required to allow compat to not fail when pypiwin32 isn't found
-os.environ["PYINSTALLER_NO_PYWIN32_FAILURE"] = "1"
-
-
-#-- plug-in building the bootloader
-
-from distutils.core import Command
-from distutils.command.build import build
-
-
-class build_bootloader(Command):
- """
- Wrapper for distutil command `build`.
- """
-
- user_options =[]
- def initialize_options(self): pass
- def finalize_options(self): pass
-
- def bootloader_exists(self):
- # Checks is the console, non-debug bootloader exists
- from PyInstaller import HOMEPATH, PLATFORM
- from PyInstaller.compat import is_win, is_cygwin
- exe = 'run'
- if is_win or is_cygwin:
- exe = 'run.exe'
- exe = os.path.join(HOMEPATH, 'PyInstaller', 'bootloader', PLATFORM, exe)
- return os.path.isfile(exe)
-
- def compile_bootloader(self):
- import subprocess
- from PyInstaller import HOMEPATH
-
- src_dir = os.path.join(HOMEPATH, 'bootloader')
- cmd = [sys.executable, './waf', 'configure', 'all']
- rc = subprocess.call(cmd, cwd=src_dir)
- if rc:
- raise SystemExit('ERROR: Failed compiling the bootloader. '
- 'Please compile manually and rerun setup.py')
-
- def run(self):
- if getattr(self, 'dry_run', False):
- return
- if self.bootloader_exists():
- return
- print('No precompiled bootloader found. Trying to compile it for you ...',
- file=sys.stderr)
- self.compile_bootloader()
-
-
-class MyBuild(build):
- # plug `build_bootloader` into the `build` command
- def run(self):
- self.run_command('build_bootloader')
- build.run(self)
-
-#--
-
-setup(
- setup_requires = ["setuptools >= 39.2.0"],
- cmdclass = {'build_bootloader': build_bootloader,
- 'build': MyBuild,
- },
-)
diff --git a/packages/p/python-requirementslib/python-requirementslib.changes b/packages/p/python-requirementslib/python-requirementslib.changes
deleted file mode 100644
index e0f6213..0000000
--- a/packages/p/python-requirementslib/python-requirementslib.changes
+++ /dev/null
@@ -1,221 +0,0 @@
--------------------------------------------------------------------
-Wed Dec 1 21:32:57 UTC 2021 - Matej Cepl
-
-- Skip failing tests test_parse_function_call_as_name,
- test_repo_line, and test_requirement_line
- (gh#sarugaku/requirementslib#303).
-
--------------------------------------------------------------------
-Tue Nov 9 15:24:16 UTC 2021 - Dominique Leuenberger
-
-- Explicitly buildrequire python-chardet: used to be pulled in by
- python-requests before.
-
--------------------------------------------------------------------
-Sun Oct 31 16:23:53 UTC 2021 - Ben Greiner
-
-- Require chardet gh#sarugaku/requirementslib#296
-
--------------------------------------------------------------------
-Mon Mar 22 21:19:50 UTC 2021 - Ben Greiner
-
-- Disable python39 build -- gh#sarugaku/requirementslib#288
-
--------------------------------------------------------------------
-Fri Nov 13 04:19:40 UTC 2020 - John Vandenberg
-
-- Set minimum versions pip-shims >= 0.5.2 & vistir >= 0.3.1
-- Add pyinstaller-setup.py to enable one of the skipped tests
-- Add test dependency git-core
-- Update to v1.5.16
- * Expand env vars in the URL of requirements
- * Replace the deprecated arguments of ``attrs`` with recommended ones
-- from v1.5.15
- * Fix a bug that file URLs will be incorrectly unquoted during parsing
-- from v1.5.14
- * Fix the PEP 517 requires in default pyproject.toml and clean temp files
- * Fix an unparse error that the dictionary keys are unhashable
- * Fix a bug that dist-info inside ``venv`` directory will be mistaken
- as the editable package's metadata
-
--------------------------------------------------------------------
-Sat Oct 17 08:31:16 UTC 2020 - John Vandenberg
-
-- Set minimum version attrs>=19.2.0
-
--------------------------------------------------------------------
-Thu Oct 15 15:36:19 UTC 2020 - Benjamin Greiner
-
-- Update to version 1.5.13
- * Don't copy whole tree for local directory dependencies. #259
-- need to skip test_no_duplicate_egg_info
- gh#sarugaku/requirementslib#270
-
--------------------------------------------------------------------
-Wed Aug 19 04:42:13 UTC 2020 - John Vandenberg
-
-- Remove build dependency on pytest-xdist
-- Add runtime dependency on python2-backports.tempfile
-- Fix injected conftest.py to support older hypothesis
-- Disable running test suite on Python 2 due to hypothesis version
- incompatibility
-- Re-add LANG in %check
-
--------------------------------------------------------------------
-Tue Jul 14 13:35:09 UTC 2020 - Benjamin Greiner
-
-- reenable offline unit tests
- * gh#sarugaku/requirementslib#145 still open
- * test_dependencies.py is completely marked with needs_internet
- * Could not reproduce the random failures
- * two parser tests fail for yet unknown reasons
-- Update to 1.5.12 (2020-07-10)
- * Bug Fixes
- * Fix a bug that assignments with type annotations are missing from
- the AST. #253
- * Fix a bug that package_dir points to a wrong location when parsing
- setup.cfg. #255
-- Update to 1.5.11 (2020-06-01)
- * Bug Fixes
- * Packages which use a function call in setup.py to find their own
- name dynamically will now successfully resolve. #251
-- Update to 1.5.10 (2020-06-01)
- * Bug Fixes
- * Switch to BFS algorithm to iterate possible metadata directories.
- #186
- * Fix a bug that + character in URL auth are converted to a space.
- #244
- * Fixed an issue in the AST parser which caused failures when
- parsing setup.py files with assignments (e.g. variable = some_value)
- to the same name more than once, followed by operations on those
- variables (e.g. new_value = variable + other_variable). #246
- * Copy symlinks as well for local path requirements. #248
- * Fix a bug that non-string value for name argument will be taken as
- requirement name. #249
-- Update to 1.5.9 (2020-05-19)
- * Bug Fixes
- * Subdirectory fragments on VCS URLs which also contain #egg=
- fragments will now be included correctly in requirements. #236
- * Fixed a regression which caused collisions to occur between valid
- named requirements and invalid local filesystem paths. #239
- * Fixed a bug in setup.py parsing in which setup.py files which
- passed a dictionary to the setup function returned metadata that could
- not be meaningfully processed. #241
-- Update to 1.5.8 (2020-05-14)
- * Bug Fixes
- * Fix an issue where the list of not-supported python versions in a
- marker was being truncated. #228
- * Fixed a bug which prevented the use of wheel_cache instances from
- pip due to deprecated invocation. #230
- * Requirementslib will now ensure that PEP508 style direct URL lines
- are preserved as being direct URL references when converting to and
- from Requirementslib.requirement instances. #232
- * Fix a bug that 1.x specifiers can't be parsed correctly. #234
-- Update to 1.5.7 (2020-04-23)
- * Bug Fixes
- * Fixed a bug in AST parsing on python 2.7 which caused the parser
- to fail if any attributes could not be resolved. #226
-- Update to 1.5.6 (2020-04-22)
- * Features
- * Added requirementslib.models.metadata module with get_package,
- get_package_version, and get_package_from_requirement interfaces. #219
- * Bug Fixes
- * Fixed an issue in parsing setup files that incorrectly parsed the
- in operator and failed to properly expand referenced dictionaries.
- #222
- * Fixed an issue that did not take into account micro versions when
- generating markers from python_requires. #223
-- Update to 1.5.5 (2020-03-31)
- * Bug Fixes
- * Fixed an issue which prevented parsing of setup.cfg files using
- the setuptools native configuration reader. #216
- * URI instances will no longer print masked username fields when
- neither a username or password is supplied. #220
-- Update to 1.5.4 (2020-03-25)
- * Features
- * Added support for hiding tokens from URLs when printing them to
- the screen. #192
- * Bug Fixes
- * Fix AST parsing when setup.py contains binary operators other than
- + and -. #179
- * Fix test failures due to updates to the pyparsing API. #181
- * Fixed an issue with loading Pipfile data due to plette model
- misalignment. #182
- * Fixed failed calls to .lower on tomlkit's Bool object during
- pipfile load as the API seems to have changed here. #183
- * Added import guards to prevent ImportErrors which could occur when
- attempting to import now-removed pkg_resources.extern.requirements.
- #185
- * Fixed an issue which prevented loading Lockfile-based references
- to local paths when calling as_requirements() on a
- requirementslib.models.lockfile.Lockfile instance. #188
- * Updated references to Link instances which no longer have the
- is_artifact property. #190
- * Updated all references to newly shimmed code to fix breakages due
- to pip 19.3 release: - Fixed references to Command object from pip in
- favor of InstallCommand which is now properly shimmed via pip-shims -
- Fixed invocation of VcsSupport and VersionControl objects for
- compatibility - Removed addition of options to Command as they are
- redundant when using InstallCommand - Cut get_finder and
- start_resolver over to newly shimmed approaches in pip-shims #191
- * Fixed a bug in parsing of Pipfiles with missing or misnamed source
- sections which could cause tomlkit errors when loading legacy
- Pipfiles. #194
- * Corrected an unexpected behavior which resulted in a KeyError when
- attempting to call __getitem__ on a Pipfile instance with a section
- that was not present. #195
- * Fixed an issue in Lockfile path and model auto-detection when
- called without the load classmethod which caused initialization to
- fail due to an AttributeError. #196
- * Fixed an issue which caused build directories to be deleted before
- dependencies could be determined for editable source reqiurements.
- #200
- * Fixed a bug which could cause parsing to fail for setup.cfg files
- on python 2. #202
- * Fixed an issue in binary operator mapping in the
- ast_parse_setup_py functionality of the dependency parser which could
- cause dependency resolution to fail. #204
- * Fixed an issue which prevented successful parsing of setup.py
- files which were not utf-8 encoded. #205
- * Fixed an issue which caused mappings of binary operators to fail
- to evaluate when parsing setup.py files. #206
- * Fixed mapping and evaluation of boolean operators and comparisons
- when evaluating setup.py files with AST parser to discover
- dependencies. #207
-
--------------------------------------------------------------------
-Sat Mar 14 07:15:44 UTC 2020 - Tomáš Chvátal
-
-- Fix build without python2
-
--------------------------------------------------------------------
-Tue Jul 23 17:14:17 UTC 2019 - Tomáš Chvátal
-
-- Update to 1.5.3:
- * Added support for parsing lists of variables as extras in setup.py files via ast.BinOp traversal. #177
- * various bugfixes
-
--------------------------------------------------------------------
-Fri Jul 19 10:44:16 UTC 2019 - Tomáš Chvátal
-
-- Do not depend on pytest-sugar, it is just pretty-formatter
-
--------------------------------------------------------------------
-Wed Jun 12 10:54:40 UTC 2019 - Marketa Calabkova
-
-- update to version 1.5.1
- * Fixed a bug which caused local dependencies to incorrectly
- return wheel as their name.
- * Implemented an AST parser for setup.py for parsing package names,
- dependencies, and version information if available.
- * Fully implement marker merging and consolidation logic using
- requirement.merge_markers(markers).
- * Fixed a bug which caused significant degradation in performance
- while loading requirements.
- * Added full support for parsing PEP-508 compliant direct URL
- dependencies.
-
--------------------------------------------------------------------
-Fri Mar 1 01:57:16 PM UTC 2019 - John Vandenberg
-
-- Initial spec for v1.4.0
diff --git a/packages/p/python-requirementslib/python-requirementslib.spec b/packages/p/python-requirementslib/python-requirementslib.spec
deleted file mode 100644
index 06dcb2c..0000000
--- a/packages/p/python-requirementslib/python-requirementslib.spec
+++ /dev/null
@@ -1,169 +0,0 @@
-#
-# spec file for package python-requirementslib
-#
-# Copyright (c) 2021 SUSE LLC
-#
-# All modifications and additions to the file contributed by third parties
-# remain the property of their copyright owners, unless otherwise agreed
-# upon. The license for this file, and modifications and additions to the
-# file, is the same license as for the pristine package itself (unless the
-# license for the pristine package is not an Open Source License, in which
-# case the license is the MIT License). An "Open Source License" is a
-# license that conforms to the Open Source Definition (Version 1.9)
-# published by the Open Source Initiative.
-
-# Please submit bugfixes or comments via https://bugs.opensuse.org/
-#
-
-
-%{?!python_module:%define python_module() python-%{**} python3-%{**}}
-# gh#sarugaku/requirementslib#288
-%define skip_python39 1
-%bcond_without python2
-Name: python-requirementslib
-Version: 1.5.16
-Release: 0
-Summary: A tool for converting between pip-style and pipfile requirements
-License: MIT
-URL: https://github.com/sarugaku/requirementslib
-Source: https://github.com/sarugaku/requirementslib/archive/%{version}.tar.gz#/requirementslib-%{version}.tar.gz
-Source1: https://raw.githubusercontent.com/mahmoud/boltons/master/LICENSE#/LICENSE.boltons
-Source2: https://raw.githubusercontent.com/pyinstaller/pyinstaller/develop/setup.py#/pyinstaller-setup.py
-Patch0: use-boltons.patch
-BuildRequires: %{python_module chardet}
-BuildRequires: %{python_module parver}
-BuildRequires: %{python_module setuptools >= 40.8}
-BuildRequires: %{python_module vistir}
-BuildRequires: %{python_module wheel}
-BuildRequires: fdupes
-BuildRequires: python-rpm-macros
-# Cerberus is suggested by plette, but required by requirementslib
-Requires: python-Cerberus
-Requires: python-appdirs
-Requires: python-attrs >= 19.2.0
-Requires: python-boltons >= 19.0.0
-Requires: python-cached-property
-Requires: python-chardet
-Requires: python-distlib >= 0.2.8
-Requires: python-first
-Requires: python-orderedmultidict
-Requires: python-packaging >= 19.0
-Requires: python-pep517 >= 0.5.0
-Requires: python-pip-shims >= 0.5.2
-Requires: python-plette
-Requires: python-requests
-Requires: python-setuptools >= 40.8
-Requires: python-six >= 1.11.0
-Requires: python-tomlkit >= 0.5.3
-Requires: python-vistir >= 0.3.1
-BuildArch: noarch
-%ifpython2
-Requires: python-backports.tempfile
-Requires: python-scandir
-Requires: python-typing
-%endif
-# SECTION test requirements
-BuildRequires: %{python_module Cerberus}
-BuildRequires: %{python_module appdirs}
-BuildRequires: %{python_module attrs >= 19.2.0}
-BuildRequires: %{python_module boltons >= 19.0.0}
-BuildRequires: %{python_module cached-property}
-BuildRequires: %{python_module chardet}
-BuildRequires: %{python_module dateutil}
-BuildRequires: %{python_module distlib >= 0.2.8}
-BuildRequires: %{python_module first}
-BuildRequires: %{python_module hypothesis}
-BuildRequires: %{python_module orderedmultidict}
-BuildRequires: %{python_module packaging >= 0.19.0}
-BuildRequires: %{python_module pep517 >= 0.5.0}
-BuildRequires: %{python_module pip-shims >= 0.5.2}
-BuildRequires: %{python_module plette}
-BuildRequires: %{python_module pytest-timeout}
-BuildRequires: %{python_module pytest}
-BuildRequires: %{python_module requests}
-BuildRequires: %{python_module six >= 1.11.0}
-BuildRequires: %{python_module tomlkit >= 0.5.3}
-BuildRequires: %{python_module twine}
-BuildRequires: %{python_module vistir >= 0.3.1}
-%if %{with python2}
-BuildRequires: python-backports.tempfile
-BuildRequires: python-scandir
-BuildRequires: python-typing
-%endif
-BuildRequires: git-core
-# /SECTION
-%python_subpackages
-
-%description
-RequirementsLib provides a simple layer for building and
-interacting with requirements in both the Pipfile format and
-the requirements.txt format. This library was originally built
-for converting between these formats in Pipenv.
-
-%prep
-%setup -q -n requirementslib-%{version}
-%patch0 -p1
-cp %{SOURCE1} .
-
-# Avoid failure during build
-sed -i '/invoke/d' setup.cfg
-
-# It is unclear whether this modified assertion is sufficient.
-# https://github.com/sarugaku/requirementslib/issues/279
-cp %{SOURCE2} tests/artifacts/git/pyinstaller/setup.py
-sed -i 's/assert "altgraph" in result\["install_requires"\]/assert "setuptools >= 39.2.0" in result["setup_requires"]/' tests/unit/test_setup_info.py
-
-%build
-export LANG=en_US.UTF-8
-%python_build
-
-%install
-export LANG=en_US.UTF-8
-%python_install
-%python_expand %fdupes %{buildroot}%{$python_sitelib}
-
-%check
-export LANG=en_US.UTF-8
-
-# many tests need internet gh#sarugaku/requirementslib#145
-# most tests are marked properly
-skip_tests="needs_internet"
-
-# depends on access to https://github.com/benjaminp/six.git
-skip_tests+=" or test_get_local_ref"
-
-# depends on access to https://github.com/jazzband/tablib/archive/v0.12.1.zip
-skip_tests+=" or test_get_requirements"
-
-# Rapptz is marker for https://github.com/Rapptz/discord.py
-skip_tests+=" or (test_convert_from_pipfile and Rapptz)"
-
-# gh#sarugaku/requirementslib#280
-skip_tests+=" or test_parse_function_call_as_name"
-
-# gh#sarugaku/requirementslib#270
-skip_tests+=" or test_no_duplicate_egg_info"
-
-# gh#sarugaku/requirementslib#303
-skip_tests+=" or test_parse_function_call_as_name or test_repo_line or test_requirement_line"
-# increase test deadline for slow obs executions architectures (e.g. on s390x)
-cat >> tests/conftest.py <>> root = {'a': {'b': {'c': [[1], [2], [3]]}}}
-- >>> get_path(root, ('a', 'b', 'c', 2, 0))
-- 3
-- The path format is intentionally consistent with that of
-- :func:`remap`.
-- One of get_path's chief aims is improved error messaging. EAFP is
-- great, but the error messages are not.
-- For instance, ``root['a']['b']['c'][2][1]`` gives back
-- ``IndexError: list index out of range``
-- What went out of range where? get_path currently raises
-- ``PathAccessError: could not access 2 from path ('a', 'b', 'c', 2,
-- 1), got error: IndexError('list index out of range',)``, a
-- subclass of IndexError and KeyError.
-- You can also pass a default that covers the entire operation,
-- should the lookup fail at any level.
-- Args:
-- root: The target nesting of dictionaries, lists, or other
-- objects supporting ``__getitem__``.
-- path (tuple): A list of strings and integers to be successively
-- looked up within *root*.
-- default: The value to be returned should any
-- ``PathAccessError`` exceptions be raised.
-- """
-- if isinstance(path, six.string_types):
-- path = path.split(".")
-- cur = root
-- try:
-- for seg in path:
-- try:
-- cur = cur[seg]
-- except (KeyError, IndexError) as exc:
-- raise PathAccessError(exc, seg, path)
-- except TypeError as exc:
-- # either string index in a list, or a parent that
-- # doesn't support indexing
-- try:
-- seg = int(seg)
-- cur = cur[seg]
-- except (ValueError, KeyError, IndexError, TypeError):
-- if not getattr(cur, "__iter__", None):
-- exc = TypeError("%r object is not indexable" % type(cur).__name__)
-- raise PathAccessError(exc, seg, path)
-- except PathAccessError:
-- if default is _UNSET:
-- raise
-- return default
-- return cur
--
--
--def default_visit(path, key, value):
-- return key, value
-+from boltons.iterutils import PathAccessError, get_path, default_visit, remap
-
-
- _orig_default_visit = default_visit
-@@ -471,6 +394,7 @@
- return value, False
- elif isinstance(value, (Mapping, dict)):
- return value.__class__(), ItemsView(value)
-+ # Handle toml containers specifically
- elif isinstance(value, tomlkit.items.Array):
- return value.__class__([], value.trivia), enumerate(value)
- elif isinstance(value, (Sequence, list)):
-@@ -517,160 +441,7 @@
- return ret
-
-
--def remap(
-- root, visit=default_visit, enter=dict_path_enter, exit=dict_path_exit, **kwargs
--):
-- """The remap ("recursive map") function is used to traverse and
-- transform nested structures. Lists, tuples, sets, and dictionaries
-- are just a few of the data structures nested into heterogenous
-- tree-like structures that are so common in programming.
-- Unfortunately, Python's built-in ways to manipulate collections
-- are almost all flat. List comprehensions may be fast and succinct,
-- but they do not recurse, making it tedious to apply quick changes
-- or complex transforms to real-world data.
-- remap goes where list comprehensions cannot.
-- Here's an example of removing all Nones from some data:
-- >>> from pprint import pprint
-- >>> reviews = {'Star Trek': {'TNG': 10, 'DS9': 8.5, 'ENT': None},
-- ... 'Babylon 5': 6, 'Dr. Who': None}
-- >>> pprint(remap(reviews, lambda p, k, v: v is not None))
-- {'Babylon 5': 6, 'Star Trek': {'DS9': 8.5, 'TNG': 10}}
-- Notice how both Nones have been removed despite the nesting in the
-- dictionary. Not bad for a one-liner, and that's just the beginning.
-- See `this remap cookbook`_ for more delicious recipes.
-- .. _this remap cookbook: http://sedimental.org/remap.html
-- remap takes four main arguments: the object to traverse and three
-- optional callables which determine how the remapped object will be
-- created.
-- Args:
-- root: The target object to traverse. By default, remap
-- supports iterables like :class:`list`, :class:`tuple`,
-- :class:`dict`, and :class:`set`, but any object traversable by
-- *enter* will work.
-- visit (callable): This function is called on every item in
-- *root*. It must accept three positional arguments, *path*,
-- *key*, and *value*. *path* is simply a tuple of parents'
-- keys. *visit* should return the new key-value pair. It may
-- also return ``True`` as shorthand to keep the old item
-- unmodified, or ``False`` to drop the item from the new
-- structure. *visit* is called after *enter*, on the new parent.
-- The *visit* function is called for every item in root,
-- including duplicate items. For traversable values, it is
-- called on the new parent object, after all its children
-- have been visited. The default visit behavior simply
-- returns the key-value pair unmodified.
-- enter (callable): This function controls which items in *root*
-- are traversed. It accepts the same arguments as *visit*: the
-- path, the key, and the value of the current item. It returns a
-- pair of the blank new parent, and an iterator over the items
-- which should be visited. If ``False`` is returned instead of
-- an iterator, the value will not be traversed.
-- The *enter* function is only called once per unique value. The
-- default enter behavior support mappings, sequences, and
-- sets. Strings and all other iterables will not be traversed.
-- exit (callable): This function determines how to handle items
-- once they have been visited. It gets the same three
-- arguments as the other functions -- *path*, *key*, *value*
-- -- plus two more: the blank new parent object returned
-- from *enter*, and a list of the new items, as remapped by
-- *visit*.
-- Like *enter*, the *exit* function is only called once per
-- unique value. The default exit behavior is to simply add
-- all new items to the new parent, e.g., using
-- :meth:`list.extend` and :meth:`dict.update` to add to the
-- new parent. Immutable objects, such as a :class:`tuple` or
-- :class:`namedtuple`, must be recreated from scratch, but
-- use the same type as the new parent passed back from the
-- *enter* function.
-- reraise_visit (bool): A pragmatic convenience for the *visit*
-- callable. When set to ``False``, remap ignores any errors
-- raised by the *visit* callback. Items causing exceptions
-- are kept. See examples for more details.
-- remap is designed to cover the majority of cases with just the
-- *visit* callable. While passing in multiple callables is very
-- empowering, remap is designed so very few cases should require
-- passing more than one function.
-- When passing *enter* and *exit*, it's common and easiest to build
-- on the default behavior. Simply add ``from boltons.iterutils import
-- default_enter`` (or ``default_exit``), and have your enter/exit
-- function call the default behavior before or after your custom
-- logic. See `this example`_.
-- Duplicate and self-referential objects (aka reference loops) are
-- automatically handled internally, `as shown here`_.
-- .. _this example: http://sedimental.org/remap.html#sort_all_lists
-- .. _as shown here: http://sedimental.org/remap.html#corner_cases
-- """
-- # TODO: improve argument formatting in sphinx doc
-- # TODO: enter() return (False, items) to continue traverse but cancel copy?
-- if not callable(visit):
-- raise TypeError("visit expected callable, not: %r" % visit)
-- if not callable(enter):
-- raise TypeError("enter expected callable, not: %r" % enter)
-- if not callable(exit):
-- raise TypeError("exit expected callable, not: %r" % exit)
-- reraise_visit = kwargs.pop("reraise_visit", True)
-- if kwargs:
-- raise TypeError("unexpected keyword arguments: %r" % kwargs.keys())
--
-- path, registry, stack = (), {}, [(None, root)]
-- new_items_stack = []
-- while stack:
-- key, value = stack.pop()
-- id_value = id(value)
-- if key is _REMAP_EXIT:
-- key, new_parent, old_parent = value
-- id_value = id(old_parent)
-- path, new_items = new_items_stack.pop()
-- value = exit(path, key, old_parent, new_parent, new_items)
-- registry[id_value] = value
-- if not new_items_stack:
-- continue
-- elif id_value in registry:
-- value = registry[id_value]
-- else:
-- res = enter(path, key, value)
-- try:
-- new_parent, new_items = res
-- except TypeError:
-- # TODO: handle False?
-- raise TypeError(
-- "enter should return a tuple of (new_parent,"
-- " items_iterator), not: %r" % res
-- )
-- if new_items is not False:
-- # traverse unless False is explicitly passed
-- registry[id_value] = new_parent
-- new_items_stack.append((path, []))
-- if value is not root:
-- path += (key,)
-- stack.append((_REMAP_EXIT, (key, new_parent, value)))
-- if new_items:
-- stack.extend(reversed(list(new_items)))
-- continue
-- if visit is _orig_default_visit:
-- # avoid function call overhead by inlining identity operation
-- visited_item = (key, value)
-- else:
-- try:
-- visited_item = visit(path, key, value)
-- except Exception:
-- if reraise_visit:
-- raise
-- visited_item = True
-- if visited_item is False:
-- continue # drop
-- elif visited_item is True:
-- visited_item = (key, value)
-- # TODO: typecheck?
-- # raise TypeError('expected (key, value) from visit(),'
-- # ' not: %r' % visited_item)
-- try:
-- new_items_stack[-1][1].append(visited_item)
-- except IndexError:
-- raise TypeError("expected remappable root, not: %r" % root)
-- return value
--
--
-+# Not sourced from boltons
- def merge_items(target_list, sourced=False):
- if not sourced:
- target_list = [(id(t), t) for t in target_list]