mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
bpo-43643: Sync with python/importlib_resources@c17a610aad. (GH-26284)
* bpo-43643: Sync with python/importlib_resources@c17a610aad. * Sync with python/importlib_resources@89fd5e961a.
This commit is contained in:
parent
b51081c1a8
commit
875b3d84b3
4 changed files with 10 additions and 1 deletions
|
@ -7,7 +7,7 @@ import types
|
||||||
import importlib
|
import importlib
|
||||||
|
|
||||||
from typing import Union, Any, Optional
|
from typing import Union, Any, Optional
|
||||||
from .abc import ResourceReader
|
from .abc import ResourceReader, Traversable
|
||||||
|
|
||||||
from ._adapters import wrap_spec
|
from ._adapters import wrap_spec
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@ Package = Union[types.ModuleType, str]
|
||||||
|
|
||||||
|
|
||||||
def files(package):
|
def files(package):
|
||||||
|
# type: (Package) -> Traversable
|
||||||
"""
|
"""
|
||||||
Get a Traversable resource from a package
|
Get a Traversable resource from a package
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -96,6 +96,7 @@ class MultiplexedPath(abc.Traversable):
|
||||||
def open(self, *args, **kwargs):
|
def open(self, *args, **kwargs):
|
||||||
raise FileNotFoundError('{} is not a file'.format(self))
|
raise FileNotFoundError('{} is not a file'.format(self))
|
||||||
|
|
||||||
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
return self._paths[0].name
|
return self._paths[0].name
|
||||||
|
|
||||||
|
|
|
@ -82,6 +82,12 @@ class MultiplexedPathTest(unittest.TestCase):
|
||||||
"MultiplexedPath('{}')".format(self.folder),
|
"MultiplexedPath('{}')".format(self.folder),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_name(self):
|
||||||
|
self.assertEqual(
|
||||||
|
MultiplexedPath(self.folder).name,
|
||||||
|
os.path.basename(self.folder),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class NamespaceReaderTest(unittest.TestCase):
|
class NamespaceReaderTest(unittest.TestCase):
|
||||||
site_dir = str(pathlib.Path(__file__).parent)
|
site_dir = str(pathlib.Path(__file__).parent)
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Declare readers.MultiplexedPath.name as a property per the spec.
|
Loading…
Add table
Add a link
Reference in a new issue