Script 'mail_helper' called by obssrc
Hello community,
here is the log from the commit of package python-importlib-resources for
openSUSE:Factory checked in at 2021-11-21 23:51:35
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-importlib-resources (Old)
and /work/SRC/openSUSE:Factory/.python-importlib-resources.new.1895 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-importlib-resources"
Sun Nov 21 23:51:35 2021 rev:3 rq:929912 version:5.4.0
Changes:
--------
---
/work/SRC/openSUSE:Factory/python-importlib-resources/python-importlib-resources.changes
2021-09-25 00:34:53.931098344 +0200
+++
/work/SRC/openSUSE:Factory/.python-importlib-resources.new.1895/python-importlib-resources.changes
2021-11-21 23:51:42.858343421 +0100
@@ -1,0 +2,11 @@
+Sat Nov 6 18:19:08 UTC 2021 - Dirk M??ller <[email protected]>
+
+- update to 5.4.0:
+ * Test suite now relies entirely on the traversable API.
+ * Now raise a ``DeprecationWarning`` for all legacy
+ functions. Instead, users should rely on the ``files()``
+ API introduced in importlib_resources 1.3. See
+ * Updated readme to reflect current behavior and show
+ which versions correspond to which behavior in CPython.
+
+-------------------------------------------------------------------
Old:
----
importlib_resources-5.2.2.tar.gz
New:
----
importlib_resources-5.4.0.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-importlib-resources.spec ++++++
--- /var/tmp/diff_new_pack.1TLwGs/_old 2021-11-21 23:51:43.370341770 +0100
+++ /var/tmp/diff_new_pack.1TLwGs/_new 2021-11-21 23:51:43.374341757 +0100
@@ -19,13 +19,13 @@
%{?!python_module:%define python3-%{**}}
%define skip_python2 1
Name: python-importlib-resources
-Version: 5.2.2
+Version: 5.4.0
Release: 0
Summary: Read resources from Python packages
License: Apache-2.0
URL: https://importlib-resources.readthedocs.io/
Source:
https://files.pythonhosted.org/packages/source/i/importlib_resources/importlib_resources-%{version}.tar.gz
-BuildRequires: %{python_module pytest}
+BuildRequires: %{python_module pytest >= 6}
BuildRequires: %{python_module setuptools_scm >= 3.4.1}
BuildRequires: %{python_module setuptools}
BuildRequires: %{python_module testsuite}
++++++ importlib_resources-5.2.2.tar.gz -> importlib_resources-5.4.0.tar.gz
++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/importlib_resources-5.2.2/.coveragerc
new/importlib_resources-5.4.0/.coveragerc
--- old/importlib_resources-5.2.2/.coveragerc 2021-07-30 23:07:29.000000000
+0200
+++ new/importlib_resources-5.4.0/.coveragerc 2021-10-30 16:50:25.000000000
+0200
@@ -3,6 +3,7 @@
# leading `*/` for pytest-dev/pytest-cov#456
*/.tox/*
*/_itertools.py
+ */_legacy.py
[report]
show_missing = True
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/importlib_resources-5.2.2/.editorconfig
new/importlib_resources-5.4.0/.editorconfig
--- old/importlib_resources-5.2.2/.editorconfig 2021-07-30 23:07:29.000000000
+0200
+++ new/importlib_resources-5.4.0/.editorconfig 2021-10-30 16:50:25.000000000
+0200
@@ -9,6 +9,7 @@
[*.py]
indent_style = space
+max_line_length = 88
[*.{yml,yaml}]
indent_style = space
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/importlib_resources-5.2.2/.github/workflows/main.yml
new/importlib_resources-5.4.0/.github/workflows/main.yml
--- old/importlib_resources-5.2.2/.github/workflows/main.yml 2021-07-30
23:07:29.000000000 +0200
+++ new/importlib_resources-5.4.0/.github/workflows/main.yml 2021-10-30
16:50:25.000000000 +0200
@@ -9,8 +9,11 @@
python:
- 3.6
- 3.9
- - 3.10.0-alpha - 3.10.99
- platform: [ubuntu-latest, macos-latest, windows-latest]
+ - "3.10"
+ platform:
+ - ubuntu-latest
+ - macos-latest
+ - windows-latest
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v2
@@ -52,7 +55,7 @@
- name: Setup Python
uses: actions/setup-python@v2
with:
- python-version: 3.9
+ python-version: "3.10"
- name: Install tox
run: |
python -m pip install tox
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/importlib_resources-5.2.2/.pre-commit-config.yaml
new/importlib_resources-5.4.0/.pre-commit-config.yaml
--- old/importlib_resources-5.2.2/.pre-commit-config.yaml 2021-07-30
23:07:29.000000000 +0200
+++ new/importlib_resources-5.4.0/.pre-commit-config.yaml 2021-10-30
16:50:25.000000000 +0200
@@ -3,8 +3,3 @@
rev: 20.8b1
hooks:
- id: black
-
-- repo: https://github.com/asottile/blacken-docs
- rev: v1.9.1
- hooks:
- - id: blacken-docs
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/importlib_resources-5.2.2/CHANGES.rst
new/importlib_resources-5.4.0/CHANGES.rst
--- old/importlib_resources-5.2.2/CHANGES.rst 2021-07-30 23:07:29.000000000
+0200
+++ new/importlib_resources-5.4.0/CHANGES.rst 2021-10-30 16:50:25.000000000
+0200
@@ -1,3 +1,30 @@
+v5.4.0
+======
+
+* *80: Test suite now relies entirely on the traversable
+ API.
+
+v5.3.0
+======
+
+* #80: Now raise a ``DeprecationWarning`` for all legacy
+ functions. Instead, users should rely on the ``files()``
+ API introduced in importlib_resources 1.3. See
+ `Migrating from Legacy
<https://importlib-resources.readthedocs.io/en/latest/using.html#migrating-from-legacy>`_
+ for guidance on avoiding the deprecated functions.
+
+v5.2.3
+======
+
+* Updated readme to reflect current behavior and show
+ which versions correspond to which behavior in CPython.
+
+v5.0.7
+======
+
+* bpo-45419: Correct ``DegenerateFiles.Path`` ``.name``
+ and ``.open()`` interfaces to match ``Traversable``.
+
v5.2.2
======
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/importlib_resources-5.2.2/PKG-INFO
new/importlib_resources-5.4.0/PKG-INFO
--- old/importlib_resources-5.2.2/PKG-INFO 2021-07-30 23:07:52.343342300
+0200
+++ new/importlib_resources-5.4.0/PKG-INFO 2021-10-30 16:50:49.532532000
+0200
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: importlib_resources
-Version: 5.2.2
+Version: 5.4.0
Summary: Read resources from Python packages
Home-page: https://github.com/python/importlib_resources
Author: Barry Warsaw
@@ -43,9 +43,7 @@
``importlib_resources`` is a backport of Python standard library
`importlib.resources
<https://docs.python.org/3/library/importlib.html#module-importlib.resources>`_
-module for older Pythons. Users of Python 3.9 and beyond
-should use the standard library module, since for these versions,
-``importlib_resources`` just delegates to that module.
+module for older Pythons.
The key goal of this module is to replace parts of `pkg_resources
<https://setuptools.readthedocs.io/en/latest/pkg_resources.html>`_ with a
@@ -53,4 +51,25 @@
reading resources included in packages easier, with more stable and consistent
semantics.
+Compatibility
+=============
+
+New features are introduced in this third-party library and later merged
+into CPython. The following table indicates which versions of this library
+were contributed to different versions in the standard library:
+
+.. list-table::
+ :header-rows: 1
+
+ * - importlib_resources
+ - stdlib
+ * - 5.2
+ - 3.11
+ * - 5.0
+ - 3.10
+ * - 1.3
+ - 3.9
+ * - 0.5 (?)
+ - 3.7
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/importlib_resources-5.2.2/README.rst
new/importlib_resources-5.4.0/README.rst
--- old/importlib_resources-5.2.2/README.rst 2021-07-30 23:07:29.000000000
+0200
+++ new/importlib_resources-5.4.0/README.rst 2021-10-30 16:50:25.000000000
+0200
@@ -23,12 +23,31 @@
``importlib_resources`` is a backport of Python standard library
`importlib.resources
<https://docs.python.org/3/library/importlib.html#module-importlib.resources>`_
-module for older Pythons. Users of Python 3.9 and beyond
-should use the standard library module, since for these versions,
-``importlib_resources`` just delegates to that module.
+module for older Pythons.
The key goal of this module is to replace parts of `pkg_resources
<https://setuptools.readthedocs.io/en/latest/pkg_resources.html>`_ with a
solution in Python's stdlib that relies on well-defined APIs. This makes
reading resources included in packages easier, with more stable and consistent
semantics.
+
+Compatibility
+=============
+
+New features are introduced in this third-party library and later merged
+into CPython. The following table indicates which versions of this library
+were contributed to different versions in the standard library:
+
+.. list-table::
+ :header-rows: 1
+
+ * - importlib_resources
+ - stdlib
+ * - 5.2
+ - 3.11
+ * - 5.0
+ - 3.10
+ * - 1.3
+ - 3.9
+ * - 0.5 (?)
+ - 3.7
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/importlib_resources-5.2.2/docs/conf.py
new/importlib_resources-5.4.0/docs/conf.py
--- old/importlib_resources-5.2.2/docs/conf.py 2021-07-30 23:07:29.000000000
+0200
+++ new/importlib_resources-5.4.0/docs/conf.py 2021-10-30 16:50:25.000000000
+0200
@@ -31,3 +31,10 @@
# Be strict about any broken references:
nitpicky = True
+
+# Include Python intersphinx mapping to prevent failures
+# jaraco/skeleton#51
+extensions += ['sphinx.ext.intersphinx']
+intersphinx_mapping = {
+ 'python': ('https://docs.python.org/3', None),
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/importlib_resources-5.2.2/docs/index.rst
new/importlib_resources-5.4.0/docs/index.rst
--- old/importlib_resources-5.2.2/docs/index.rst 2021-07-30
23:07:29.000000000 +0200
+++ new/importlib_resources-5.4.0/docs/index.rst 2021-10-30
16:50:25.000000000 +0200
@@ -11,11 +11,13 @@
zip file, with support for other loader_ classes that implement the appropriate
API for reading resources.
-``importlib_resources`` is a backport of Python 3.9's standard library
-`importlib.resources`_ module for Python 2.7, and 3.5 through 3.8. Users of
-Python 3.9 and beyond are encouraged to use the standard library module.
-Developers looking for detailed API descriptions should refer to the Python
-3.9 standard library documentation.
+``importlib_resources`` supplies a backport of
+:doc:`importlib.resources <library/importlib>`,
+enabling early access to features of future Python versions and making
+functionality available for older Python versions. Users are encouraged to
+use the Python standard library where suitable and fall back to
+this library for future compatibility. Developers looking for detailed API
+descriptions should refer to the standard library documentation.
The documentation here includes a general :ref:`usage <using>` guide and a
:ref:`migration <migration>` guide for projects that want to adopt
@@ -39,7 +41,6 @@
* :ref:`search`
-.. _`importlib.resources`:
https://docs.python.org/3.7/library/importlib.html#module-importlib.resources
.. _`Basic Resource Access`:
http://setuptools.readthedocs.io/en/latest/pkg_resources.html#basic-resource-access
.. _`Python package`: https://docs.python.org/3/reference/import.html#packages
.. _loader: https://docs.python.org/3/reference/import.html#finders-and-loaders
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/importlib_resources-5.2.2/docs/using.rst
new/importlib_resources-5.4.0/docs/using.rst
--- old/importlib_resources-5.2.2/docs/using.rst 2021-07-30
23:07:29.000000000 +0200
+++ new/importlib_resources-5.4.0/docs/using.rst 2021-10-30
16:50:25.000000000 +0200
@@ -163,6 +163,23 @@
Both relative and absolute paths work for Python 3.7 and newer.
+Migrating from Legacy
+=====================
+
+Starting with Python 3.9 and ``importlib_resources`` 1.4, this package
+introduced the ``files()`` API, to be preferred over the legacy API,
+i.e. the functions ``open_binary``, ``open_text``, ``path``,
+``contents``, ``read_text``, ``read_binary``, and ``is_resource``.
+
+To port to the ``files()`` API, refer to the
+`_legacy module
<https://github.com/python/importlib_resources/blob/66ea2dc7eb12b1be2322b7ad002cefb12d364dff/importlib_resources/_legacy.py>`_
+to see simple wrappers that enable drop-in replacement based on the
+preferred API, and either copy those or adapt the usage to utilize the
+``files`` and
+`Traversable
<https://github.com/python/importlib_resources/blob/b665a3ea907d93b1b6457217f34e1bfc06f51fe6/importlib_resources/abc.py#L49-L114>`_
+interfaces directly.
+
+
Extending
=========
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/importlib_resources-5.2.2/importlib_resources/__init__.py
new/importlib_resources-5.4.0/importlib_resources/__init__.py
--- old/importlib_resources-5.2.2/importlib_resources/__init__.py
2021-07-30 23:07:29.000000000 +0200
+++ new/importlib_resources-5.4.0/importlib_resources/__init__.py
2021-10-30 16:50:25.000000000 +0200
@@ -4,7 +4,6 @@
as_file,
files,
Package,
- Resource,
)
from ._legacy import (
@@ -15,6 +14,7 @@
read_text,
is_resource,
path,
+ Resource,
)
from importlib_resources.abc import ResourceReader
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/importlib_resources-5.2.2/importlib_resources/_adapters.py
new/importlib_resources-5.4.0/importlib_resources/_adapters.py
--- old/importlib_resources-5.2.2/importlib_resources/_adapters.py
2021-07-30 23:07:29.000000000 +0200
+++ new/importlib_resources-5.4.0/importlib_resources/_adapters.py
2021-10-30 16:50:25.000000000 +0200
@@ -41,8 +41,8 @@
class CompatibilityFiles:
"""
- Adapter for an existing or non-existant resource reader
- to provide a compability .files().
+ Adapter for an existing or non-existent resource reader
+ to provide a compatibility .files().
"""
class SpecPath(abc.Traversable):
@@ -83,7 +83,7 @@
class ChildPath(abc.Traversable):
"""
Path tied to a resource reader child.
- Can be read but doesn't expose any meaningfull children.
+ Can be read but doesn't expose any meaningful children.
"""
def __init__(self, reader, name):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/importlib_resources-5.2.2/importlib_resources/_common.py
new/importlib_resources-5.4.0/importlib_resources/_common.py
--- old/importlib_resources-5.2.2/importlib_resources/_common.py
2021-07-30 23:07:29.000000000 +0200
+++ new/importlib_resources-5.4.0/importlib_resources/_common.py
2021-10-30 16:50:25.000000000 +0200
@@ -6,13 +6,12 @@
import types
import importlib
-from typing import Union, Any, Optional
+from typing import Union, Optional
from .abc import ResourceReader, Traversable
from ._compat import wrap_spec
Package = Union[types.ModuleType, str]
-Resource = Union[str, os.PathLike]
def files(package):
@@ -23,19 +22,6 @@
return from_package(get_package(package))
-def normalize_path(path):
- # type: (Any) -> str
- """Normalize a path by ensuring it is a string.
-
- If the resulting string contains path separators, an exception is raised.
- """
- str_path = str(path)
- parent, file_name = os.path.split(str_path)
- if parent:
- raise ValueError(f'{path!r} must be only a file name')
- return file_name
-
-
def get_resource_reader(package):
# type: (types.ModuleType) -> Optional[ResourceReader]
"""
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/importlib_resources-5.2.2/importlib_resources/_itertools.py
new/importlib_resources-5.4.0/importlib_resources/_itertools.py
--- old/importlib_resources-5.2.2/importlib_resources/_itertools.py
2021-07-30 23:07:29.000000000 +0200
+++ new/importlib_resources-5.4.0/importlib_resources/_itertools.py
2021-10-30 16:50:25.000000000 +0200
@@ -1,11 +1,27 @@
from itertools import filterfalse
+from typing import (
+ Callable,
+ Iterable,
+ Iterator,
+ Optional,
+ Set,
+ TypeVar,
+ Union,
+)
-def unique_everseen(iterable, key=None):
+# Type and type variable definitions
+_T = TypeVar('_T')
+_U = TypeVar('_U')
+
+
+def unique_everseen(
+ iterable: Iterable[_T], key: Optional[Callable[[_T], _U]] = None
+) -> Iterator[_T]:
"List unique elements, preserving order. Remember all elements ever seen."
# unique_everseen('AAAABBBCCDAABBB') --> A B C D
# unique_everseen('ABBCcAD', str.lower) --> A B C D
- seen = set()
+ seen: Set[Union[_T, _U]] = set()
seen_add = seen.add
if key is None:
for element in filterfalse(seen.__contains__, iterable):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/importlib_resources-5.2.2/importlib_resources/_legacy.py
new/importlib_resources-5.4.0/importlib_resources/_legacy.py
--- old/importlib_resources-5.2.2/importlib_resources/_legacy.py
2021-07-30 23:07:29.000000000 +0200
+++ new/importlib_resources-5.4.0/importlib_resources/_legacy.py
2021-10-30 16:50:25.000000000 +0200
@@ -1,25 +1,58 @@
+import functools
import os
import pathlib
import types
+import warnings
-from typing import Union, Iterable, ContextManager, BinaryIO, TextIO
+from typing import Union, Iterable, ContextManager, BinaryIO, TextIO, Any
from . import _common
Package = Union[types.ModuleType, str]
-Resource = Union[str, os.PathLike]
+Resource = str
+def deprecated(func):
+ @functools.wraps(func)
+ def wrapper(*args, **kwargs):
+ warnings.warn(
+ f"{func.__name__} is deprecated. Use files() instead. "
+ "Refer to https://importlib-resources.readthedocs.io"
+ "/en/latest/using.html#migrating-from-legacy for migration
advice.",
+ DeprecationWarning,
+ stacklevel=2,
+ )
+ return func(*args, **kwargs)
+
+ return wrapper
+
+
+def normalize_path(path):
+ # type: (Any) -> str
+ """Normalize a path by ensuring it is a string.
+
+ If the resulting string contains path separators, an exception is raised.
+ """
+ str_path = str(path)
+ parent, file_name = os.path.split(str_path)
+ if parent:
+ raise ValueError(f'{path!r} must be only a file name')
+ return file_name
+
+
+@deprecated
def open_binary(package: Package, resource: Resource) -> BinaryIO:
"""Return a file-like object opened for binary reading of the resource."""
- return (_common.files(package) /
_common.normalize_path(resource)).open('rb')
+ return (_common.files(package) / normalize_path(resource)).open('rb')
+@deprecated
def read_binary(package: Package, resource: Resource) -> bytes:
"""Return the binary contents of the resource."""
- return (_common.files(package) /
_common.normalize_path(resource)).read_bytes()
+ return (_common.files(package) / normalize_path(resource)).read_bytes()
+@deprecated
def open_text(
package: Package,
resource: Resource,
@@ -27,11 +60,12 @@
errors: str = 'strict',
) -> TextIO:
"""Return a file-like object opened for text reading of the resource."""
- return (_common.files(package) / _common.normalize_path(resource)).open(
+ return (_common.files(package) / normalize_path(resource)).open(
'r', encoding=encoding, errors=errors
)
+@deprecated
def read_text(
package: Package,
resource: Resource,
@@ -47,6 +81,7 @@
return fp.read()
+@deprecated
def contents(package: Package) -> Iterable[str]:
"""Return an iterable of entries in `package`.
@@ -57,18 +92,20 @@
return [path.name for path in _common.files(package).iterdir()]
+@deprecated
def is_resource(package: Package, name: str) -> bool:
"""True if `name` is a resource inside `package`.
Directories are *not* resources.
"""
- resource = _common.normalize_path(name)
+ resource = normalize_path(name)
return any(
traversable.name == resource and traversable.is_file()
for traversable in _common.files(package).iterdir()
)
+@deprecated
def path(
package: Package,
resource: Resource,
@@ -81,4 +118,4 @@
raised if the file was deleted prior to the context manager
exiting).
"""
- return _common.as_file(_common.files(package) /
_common.normalize_path(resource))
+ return _common.as_file(_common.files(package) / normalize_path(resource))
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/importlib_resources-5.2.2/importlib_resources/abc.py
new/importlib_resources-5.4.0/importlib_resources/abc.py
--- old/importlib_resources-5.2.2/importlib_resources/abc.py 2021-07-30
23:07:29.000000000 +0200
+++ new/importlib_resources-5.4.0/importlib_resources/abc.py 2021-10-30
16:50:25.000000000 +0200
@@ -76,7 +76,7 @@
@abc.abstractmethod
def is_dir(self) -> bool:
"""
- Return True if self is a dir
+ Return True if self is a directory
"""
@abc.abstractmethod
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/importlib_resources-5.2.2/importlib_resources/tests/test_contents.py
new/importlib_resources-5.4.0/importlib_resources/tests/test_contents.py
--- old/importlib_resources-5.2.2/importlib_resources/tests/test_contents.py
2021-07-30 23:07:29.000000000 +0200
+++ new/importlib_resources-5.4.0/importlib_resources/tests/test_contents.py
2021-10-30 16:50:25.000000000 +0200
@@ -15,7 +15,8 @@
}
def test_contents(self):
- assert self.expected <= set(resources.contents(self.data))
+ contents = {path.name for path in resources.files(self.data).iterdir()}
+ assert self.expected <= contents
class ContentsDiskTests(ContentsTests, unittest.TestCase):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/importlib_resources-5.2.2/importlib_resources/tests/test_open.py
new/importlib_resources-5.4.0/importlib_resources/tests/test_open.py
--- old/importlib_resources-5.2.2/importlib_resources/tests/test_open.py
2021-07-30 23:07:29.000000000 +0200
+++ new/importlib_resources-5.4.0/importlib_resources/tests/test_open.py
2021-10-30 16:50:25.000000000 +0200
@@ -7,37 +7,43 @@
class CommonBinaryTests(util.CommonTests, unittest.TestCase):
def execute(self, package, path):
- with resources.open_binary(package, path):
+ target = resources.files(package).joinpath(path)
+ with target.open('rb'):
pass
class CommonTextTests(util.CommonTests, unittest.TestCase):
def execute(self, package, path):
- with resources.open_text(package, path):
+ target = resources.files(package).joinpath(path)
+ with target.open():
pass
class OpenTests:
def test_open_binary(self):
- with resources.open_binary(self.data, 'utf-8.file') as fp:
+ target = resources.files(self.data) / 'binary.file'
+ with target.open('rb') as fp:
result = fp.read()
- self.assertEqual(result, b'Hello, UTF-8 world!\n')
+ self.assertEqual(result, b'\x00\x01\x02\x03')
def test_open_text_default_encoding(self):
- with resources.open_text(self.data, 'utf-8.file') as fp:
+ target = resources.files(self.data) / 'utf-8.file'
+ with target.open() as fp:
result = fp.read()
self.assertEqual(result, 'Hello, UTF-8 world!\n')
def test_open_text_given_encoding(self):
- with resources.open_text(self.data, 'utf-16.file', 'utf-16', 'strict')
as fp:
+ target = resources.files(self.data) / 'utf-16.file'
+ with target.open(encoding='utf-16', errors='strict') as fp:
result = fp.read()
self.assertEqual(result, 'Hello, UTF-16 world!\n')
def test_open_text_with_errors(self):
# Raises UnicodeError without the 'errors' argument.
- with resources.open_text(self.data, 'utf-16.file', 'utf-8', 'strict')
as fp:
+ target = resources.files(self.data) / 'utf-16.file'
+ with target.open(encoding='utf-8', errors='strict') as fp:
self.assertRaises(UnicodeError, fp.read)
- with resources.open_text(self.data, 'utf-16.file', 'utf-8', 'ignore')
as fp:
+ with target.open(encoding='utf-8', errors='ignore') as fp:
result = fp.read()
self.assertEqual(
result,
@@ -47,14 +53,12 @@
)
def test_open_binary_FileNotFoundError(self):
- self.assertRaises(
- FileNotFoundError, resources.open_binary, self.data,
'does-not-exist'
- )
+ target = resources.files(self.data) / 'does-not-exist'
+ self.assertRaises(FileNotFoundError, target.open, 'rb')
def test_open_text_FileNotFoundError(self):
- self.assertRaises(
- FileNotFoundError, resources.open_text, self.data, 'does-not-exist'
- )
+ target = resources.files(self.data) / 'does-not-exist'
+ self.assertRaises(FileNotFoundError, target.open)
class OpenDiskTests(OpenTests, unittest.TestCase):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/importlib_resources-5.2.2/importlib_resources/tests/test_path.py
new/importlib_resources-5.4.0/importlib_resources/tests/test_path.py
--- old/importlib_resources-5.2.2/importlib_resources/tests/test_path.py
2021-07-30 23:07:29.000000000 +0200
+++ new/importlib_resources-5.4.0/importlib_resources/tests/test_path.py
2021-10-30 16:50:25.000000000 +0200
@@ -8,7 +8,7 @@
class CommonTests(util.CommonTests, unittest.TestCase):
def execute(self, package, path):
- with resources.path(package, path):
+ with resources.as_file(resources.files(package).joinpath(path)):
pass
@@ -17,7 +17,8 @@
# Path should be readable.
# Test also implicitly verifies the returned object is a pathlib.Path
# instance.
- with resources.path(self.data, 'utf-8.file') as path:
+ target = resources.files(self.data) / 'utf-8.file'
+ with resources.as_file(target) as path:
self.assertTrue(path.name.endswith("utf-8.file"), repr(path))
# pathlib.Path.read_text() was introduced in Python 3.5.
with path.open('r', encoding='utf-8') as file:
@@ -34,7 +35,8 @@
file-system-backed resources do not get the tempdir
treatment.
"""
- with resources.path(self.data, 'utf-8.file') as path:
+ target = resources.files(self.data) / 'utf-8.file'
+ with resources.as_file(target) as path:
assert 'data' in str(path)
@@ -53,7 +55,8 @@
def test_remove_in_context_manager(self):
# It is not an error if the file that was temporarily stashed on the
# file system is removed inside the `with` stanza.
- with resources.path(self.data, 'utf-8.file') as path:
+ target = resources.files(self.data) / 'utf-8.file'
+ with resources.as_file(target) as path:
path.unlink()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/importlib_resources-5.2.2/importlib_resources/tests/test_read.py
new/importlib_resources-5.4.0/importlib_resources/tests/test_read.py
--- old/importlib_resources-5.2.2/importlib_resources/tests/test_read.py
2021-07-30 23:07:29.000000000 +0200
+++ new/importlib_resources-5.4.0/importlib_resources/tests/test_read.py
2021-10-30 16:50:25.000000000 +0200
@@ -8,31 +8,36 @@
class CommonBinaryTests(util.CommonTests, unittest.TestCase):
def execute(self, package, path):
- resources.read_binary(package, path)
+ resources.files(package).joinpath(path).read_bytes()
class CommonTextTests(util.CommonTests, unittest.TestCase):
def execute(self, package, path):
- resources.read_text(package, path)
+ resources.files(package).joinpath(path).read_text()
class ReadTests:
- def test_read_binary(self):
- result = resources.read_binary(self.data, 'binary.file')
+ def test_read_bytes(self):
+ result =
resources.files(self.data).joinpath('binary.file').read_bytes()
self.assertEqual(result, b'\0\1\2\3')
def test_read_text_default_encoding(self):
- result = resources.read_text(self.data, 'utf-8.file')
+ result = resources.files(self.data).joinpath('utf-8.file').read_text()
self.assertEqual(result, 'Hello, UTF-8 world!\n')
def test_read_text_given_encoding(self):
- result = resources.read_text(self.data, 'utf-16.file',
encoding='utf-16')
+ result = (
+ resources.files(self.data)
+ .joinpath('utf-16.file')
+ .read_text(encoding='utf-16')
+ )
self.assertEqual(result, 'Hello, UTF-16 world!\n')
def test_read_text_with_errors(self):
# Raises UnicodeError without the 'errors' argument.
- self.assertRaises(UnicodeError, resources.read_text, self.data,
'utf-16.file')
- result = resources.read_text(self.data, 'utf-16.file', errors='ignore')
+ target = resources.files(self.data) / 'utf-16.file'
+ self.assertRaises(UnicodeError, target.read_text, encoding='utf-8')
+ result = target.read_text(encoding='utf-8', errors='ignore')
self.assertEqual(
result,
'H\x00e\x00l\x00l\x00o\x00,\x00 '
@@ -48,11 +53,15 @@
class ReadZipTests(ReadTests, util.ZipSetup, unittest.TestCase):
def test_read_submodule_resource(self):
submodule = import_module('ziptestdata.subdirectory')
- result = resources.read_binary(submodule, 'binary.file')
+ result =
resources.files(submodule).joinpath('binary.file').read_bytes()
self.assertEqual(result, b'\0\1\2\3')
def test_read_submodule_resource_by_name(self):
- result = resources.read_binary('ziptestdata.subdirectory',
'binary.file')
+ result = (
+ resources.files('ziptestdata.subdirectory')
+ .joinpath('binary.file')
+ .read_bytes()
+ )
self.assertEqual(result, b'\0\1\2\3')
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/importlib_resources-5.2.2/importlib_resources/tests/test_resource.py
new/importlib_resources-5.4.0/importlib_resources/tests/test_resource.py
--- old/importlib_resources-5.2.2/importlib_resources/tests/test_resource.py
2021-07-30 23:07:29.000000000 +0200
+++ new/importlib_resources-5.4.0/importlib_resources/tests/test_resource.py
2021-10-30 16:50:25.000000000 +0200
@@ -14,34 +14,18 @@
class ResourceTests:
# Subclasses are expected to set the `data` attribute.
- def test_is_resource_good_path(self):
- self.assertTrue(resources.is_resource(self.data, 'binary.file'))
-
- def test_is_resource_missing(self):
- self.assertFalse(resources.is_resource(self.data, 'not-a-file'))
-
- def test_is_resource_subresource_directory(self):
- # Directories are not resources.
- self.assertFalse(resources.is_resource(self.data, 'subdirectory'))
-
- def test_contents(self):
- contents = set(resources.contents(self.data))
- # There may be cruft in the directory listing of the data directory.
- # It could have a __pycache__ directory,
- # an artifact of the
- # test suite importing these modules, which
- # are not germane to this test, so just filter them out.
- contents.discard('__pycache__')
- self.assertEqual(
- sorted(contents),
- [
- '__init__.py',
- 'binary.file',
- 'subdirectory',
- 'utf-16.file',
- 'utf-8.file',
- ],
- )
+ def test_is_file_exists(self):
+ target = resources.files(self.data) / 'binary.file'
+ self.assertTrue(target.is_file())
+
+ def test_is_file_missing(self):
+ target = resources.files(self.data) / 'not-a-file'
+ self.assertFalse(target.is_file())
+
+ def test_is_dir(self):
+ target = resources.files(self.data) / 'subdirectory'
+ self.assertFalse(target.is_file())
+ self.assertTrue(target.is_dir())
class ResourceDiskTests(ResourceTests, unittest.TestCase):
@@ -53,30 +37,34 @@
pass
+def names(traversable):
+ return {item.name for item in traversable.iterdir()}
+
+
class ResourceLoaderTests(unittest.TestCase):
def test_resource_contents(self):
package = util.create_package(
file=data01, path=data01.__file__, contents=['A', 'B', 'C']
)
- self.assertEqual(set(resources.contents(package)), {'A', 'B', 'C'})
+ self.assertEqual(names(resources.files(package)), {'A', 'B', 'C'})
- def test_resource_is_resource(self):
+ def test_is_file(self):
package = util.create_package(
file=data01, path=data01.__file__, contents=['A', 'B', 'C', 'D/E',
'D/F']
)
- self.assertTrue(resources.is_resource(package, 'B'))
+ self.assertTrue(resources.files(package).joinpath('B').is_file())
- def test_resource_directory_is_not_resource(self):
+ def test_is_dir(self):
package = util.create_package(
file=data01, path=data01.__file__, contents=['A', 'B', 'C', 'D/E',
'D/F']
)
- self.assertFalse(resources.is_resource(package, 'D'))
+ self.assertTrue(resources.files(package).joinpath('D').is_dir())
- def test_resource_missing_is_not_resource(self):
+ def test_resource_missing(self):
package = util.create_package(
file=data01, path=data01.__file__, contents=['A', 'B', 'C', 'D/E',
'D/F']
)
- self.assertFalse(resources.is_resource(package, 'Z'))
+ self.assertFalse(resources.files(package).joinpath('Z').is_file())
class ResourceCornerCaseTests(unittest.TestCase):
@@ -94,7 +82,7 @@
module.__file__ = '/path/which/shall/not/be/named'
module.__spec__.loader = module.__loader__
module.__spec__.origin = module.__file__
- self.assertFalse(resources.is_resource(module, 'A'))
+ self.assertFalse(resources.files(module).joinpath('A').is_file())
class ResourceFromZipsTest01(util.ZipSetupBase, unittest.TestCase):
@@ -102,22 +90,24 @@
def test_is_submodule_resource(self):
submodule = import_module('ziptestdata.subdirectory')
- self.assertTrue(resources.is_resource(submodule, 'binary.file'))
+
self.assertTrue(resources.files(submodule).joinpath('binary.file').is_file())
def test_read_submodule_resource_by_name(self):
self.assertTrue(
- resources.is_resource('ziptestdata.subdirectory', 'binary.file')
+ resources.files('ziptestdata.subdirectory')
+ .joinpath('binary.file')
+ .is_file()
)
def test_submodule_contents(self):
submodule = import_module('ziptestdata.subdirectory')
self.assertEqual(
- set(resources.contents(submodule)), {'__init__.py', 'binary.file'}
+ names(resources.files(submodule)), {'__init__.py', 'binary.file'}
)
def test_submodule_contents_by_name(self):
self.assertEqual(
- set(resources.contents('ziptestdata.subdirectory')),
+ names(resources.files('ziptestdata.subdirectory')),
{'__init__.py', 'binary.file'},
)
@@ -131,10 +121,12 @@
distinct resources. Ref python/importlib_resources#44.
"""
self.assertEqual(
- set(resources.contents('ziptestdata.one')), {'__init__.py',
'resource1.txt'}
+ names(resources.files('ziptestdata.one')),
+ {'__init__.py', 'resource1.txt'},
)
self.assertEqual(
- set(resources.contents('ziptestdata.two')), {'__init__.py',
'resource2.txt'}
+ names(resources.files('ziptestdata.two')),
+ {'__init__.py', 'resource2.txt'},
)
@@ -175,41 +167,43 @@
# If the test fails, this will probably fail too
pass
- def test_contents_does_not_keep_open(self):
- c = resources.contents('ziptestdata')
+ def test_iterdir_does_not_keep_open(self):
+ c = [item.name for item in resources.files('ziptestdata').iterdir()]
self.zip_path.unlink()
del c
- def test_is_resource_does_not_keep_open(self):
- c = resources.is_resource('ziptestdata', 'binary.file')
+ def test_is_file_does_not_keep_open(self):
+ c = resources.files('ziptestdata').joinpath('binary.file').is_file()
self.zip_path.unlink()
del c
- def test_is_resource_failure_does_not_keep_open(self):
- c = resources.is_resource('ziptestdata', 'not-present')
+ def test_is_file_failure_does_not_keep_open(self):
+ c = resources.files('ziptestdata').joinpath('not-present').is_file()
self.zip_path.unlink()
del c
@unittest.skip("Desired but not supported.")
- def test_path_does_not_keep_open(self):
- c = resources.path('ziptestdata', 'binary.file')
+ def test_as_file_does_not_keep_open(self): # pragma: no cover
+ c = resources.as_file(resources.files('ziptestdata') / 'binary.file')
self.zip_path.unlink()
del c
def test_entered_path_does_not_keep_open(self):
# This is what certifi does on import to make its bundle
# available for the process duration.
- c = resources.path('ziptestdata', 'binary.file').__enter__()
+ c = resources.as_file(
+ resources.files('ziptestdata') / 'binary.file'
+ ).__enter__()
self.zip_path.unlink()
del c
def test_read_binary_does_not_keep_open(self):
- c = resources.read_binary('ziptestdata', 'binary.file')
+ c = resources.files('ziptestdata').joinpath('binary.file').read_bytes()
self.zip_path.unlink()
del c
def test_read_text_does_not_keep_open(self):
- c = resources.read_text('ziptestdata', 'utf-8.file', encoding='utf-8')
+ c = resources.files('ziptestdata').joinpath('utf-8.file').read_text()
self.zip_path.unlink()
del c
@@ -227,14 +221,18 @@
def test_is_submodule_resource(self):
self.assertTrue(
- resources.is_resource(import_module('namespacedata01'),
'binary.file')
+ resources.files(import_module('namespacedata01'))
+ .joinpath('binary.file')
+ .is_file()
)
def test_read_submodule_resource_by_name(self):
- self.assertTrue(resources.is_resource('namespacedata01',
'binary.file'))
+ self.assertTrue(
+
resources.files('namespacedata01').joinpath('binary.file').is_file()
+ )
def test_submodule_contents(self):
- contents = set(resources.contents(import_module('namespacedata01')))
+ contents = names(resources.files(import_module('namespacedata01')))
try:
contents.remove('__pycache__')
except KeyError:
@@ -242,7 +240,7 @@
self.assertEqual(contents, {'binary.file', 'utf-8.file',
'utf-16.file'})
def test_submodule_contents_by_name(self):
- contents = set(resources.contents('namespacedata01'))
+ contents = names(resources.files('namespacedata01'))
try:
contents.remove('__pycache__')
except KeyError:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/importlib_resources-5.2.2/importlib_resources/tests/util.py
new/importlib_resources-5.4.0/importlib_resources/tests/util.py
--- old/importlib_resources-5.2.2/importlib_resources/tests/util.py
2021-07-30 23:07:29.000000000 +0200
+++ new/importlib_resources-5.4.0/importlib_resources/tests/util.py
2021-10-30 16:50:25.000000000 +0200
@@ -97,18 +97,6 @@
path = PurePath('utf-8.file')
self.execute(data01, path)
- def test_absolute_path(self):
- # An absolute path is a ValueError.
- path = Path(__file__)
- full_path = path.parent / 'utf-8.file'
- with self.assertRaises(ValueError):
- self.execute(data01, full_path)
-
- def test_relative_path(self):
- # A reative path is a ValueError.
- with self.assertRaises(ValueError):
- self.execute(data01, '../data01/utf-8.file')
-
def test_importing_module_as_side_effect(self):
# The anchor package can already be imported.
del sys.modules[data01.__name__]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/importlib_resources-5.2.2/importlib_resources.egg-info/PKG-INFO
new/importlib_resources-5.4.0/importlib_resources.egg-info/PKG-INFO
--- old/importlib_resources-5.2.2/importlib_resources.egg-info/PKG-INFO
2021-07-30 23:07:52.000000000 +0200
+++ new/importlib_resources-5.4.0/importlib_resources.egg-info/PKG-INFO
2021-10-30 16:50:49.000000000 +0200
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: importlib-resources
-Version: 5.2.2
+Version: 5.4.0
Summary: Read resources from Python packages
Home-page: https://github.com/python/importlib_resources
Author: Barry Warsaw
@@ -43,9 +43,7 @@
``importlib_resources`` is a backport of Python standard library
`importlib.resources
<https://docs.python.org/3/library/importlib.html#module-importlib.resources>`_
-module for older Pythons. Users of Python 3.9 and beyond
-should use the standard library module, since for these versions,
-``importlib_resources`` just delegates to that module.
+module for older Pythons.
The key goal of this module is to replace parts of `pkg_resources
<https://setuptools.readthedocs.io/en/latest/pkg_resources.html>`_ with a
@@ -53,4 +51,25 @@
reading resources included in packages easier, with more stable and consistent
semantics.
+Compatibility
+=============
+
+New features are introduced in this third-party library and later merged
+into CPython. The following table indicates which versions of this library
+were contributed to different versions in the standard library:
+
+.. list-table::
+ :header-rows: 1
+
+ * - importlib_resources
+ - stdlib
+ * - 5.2
+ - 3.11
+ * - 5.0
+ - 3.10
+ * - 1.3
+ - 3.9
+ * - 0.5 (?)
+ - 3.7
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/importlib_resources-5.2.2/importlib_resources.egg-info/requires.txt
new/importlib_resources-5.4.0/importlib_resources.egg-info/requires.txt
--- old/importlib_resources-5.2.2/importlib_resources.egg-info/requires.txt
2021-07-30 23:07:52.000000000 +0200
+++ new/importlib_resources-5.4.0/importlib_resources.egg-info/requires.txt
2021-10-30 16:50:49.000000000 +0200
@@ -8,7 +8,7 @@
rst.linker>=1.9
[testing]
-pytest>=4.6
+pytest>=6
pytest-checkdocs>=2.4
pytest-flake8
pytest-cov
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/importlib_resources-5.2.2/pytest.ini
new/importlib_resources-5.4.0/pytest.ini
--- old/importlib_resources-5.2.2/pytest.ini 2021-07-30 23:07:29.000000000
+0200
+++ new/importlib_resources-5.4.0/pytest.ini 2021-10-30 16:50:25.000000000
+0200
@@ -2,8 +2,6 @@
norecursedirs=dist build .tox .eggs
addopts=--doctest-modules
doctest_optionflags=ALLOW_UNICODE ELLIPSIS
-# workaround for warning pytest-dev/pytest#6178
-junit_family=xunit2
filterwarnings=
# Suppress deprecation warning in flake8
ignore:SelectableGroups dict interface is deprecated::flake8
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/importlib_resources-5.2.2/setup.cfg
new/importlib_resources-5.4.0/setup.cfg
--- old/importlib_resources-5.2.2/setup.cfg 2021-07-30 23:07:52.343342300
+0200
+++ new/importlib_resources-5.4.0/setup.cfg 2021-10-30 16:50:49.532532000
+0200
@@ -30,7 +30,7 @@
[options.extras_require]
testing =
- pytest >= 4.6
+ pytest >= 6
pytest-checkdocs >= 2.4
pytest-flake8
pytest-black >= 0.3.7; \