@@ -233,7 +233,6 @@ ABC hierarchy::
233233 | +-- MetaPathFinder
234234 | +-- PathEntryFinder
235235 +-- Loader
236- +-- ResourceReader
237236 +-- ResourceLoader --------+
238237 +-- InspectLoader |
239238 +-- ExecutionLoader --+
@@ -370,6 +369,13 @@ ABC hierarchy::
370369 An abstract base class for a :term: `loader `.
371370 See :pep: `302 ` for the exact definition for a loader.
372371
372+ For loaders that wish to support resource reading, they should
373+ implement a ``get_resource_reader(fullname) `` method as specified
374+ by :class: `importlib.abc.ResourceReader `.
375+
376+ .. versionchanged :: 3.7
377+ Introduced the optional ``get_resource_reader() `` method.
378+
373379 .. method :: create_module(spec)
374380
375381 A method that returns the module object to use when
@@ -471,8 +477,7 @@ ABC hierarchy::
471477
472478.. class :: ResourceReader
473479
474- An :term: `abstract base class ` for :term: `package `
475- :term: `loaders <loader> ` to provide the ability to read
480+ An :term: `abstract base class ` to provide the ability to read
476481 *resources *.
477482
478483 From the perspective of this ABC, a *resource * is a binary
@@ -487,13 +492,20 @@ ABC hierarchy::
487492 expected to be a :term: `path-like object ` which represents
488493 conceptually just a file name. This means that no subdirectory
489494 paths should be included in the *resource * argument. This is
490- because the location of the package that the loader is for acts
491- as the "directory". Hence the metaphor for directories and file
495+ because the location of the package the reader is for, acts as the
496+ "directory". Hence the metaphor for directories and file
492497 names is packages and resources, respectively. This is also why
493498 instances of this class are expected to directly correlate to
494499 a specific package (instead of potentially representing multiple
495500 packages or a module).
496501
502+ Loaders that wish to support resource reading are expected to
503+ provide a method called ``get_resource_loader(fullname) `` which
504+ returns an object implementing this ABC's interface. If the module
505+ specified by fullname is not a package, this method should return
506+ :const: `None `. An object compatible with this ABC should only be
507+ returned when the specified module is a package.
508+
497509 .. versionadded :: 3.7
498510
499511 .. abstractmethod :: open_resource(resource)
@@ -529,9 +541,10 @@ ABC hierarchy::
529541 are known a priori and the non-resource names would be useful.
530542 For instance, returning subdirectory names is allowed so that
531543 when it is known that the package and resources are stored on
532- the file system then those subdirectory names can be used.
544+ the file system then those subdirectory names can be used
545+ directly.
533546
534- The abstract method returns an empty iterator.
547+ The abstract method returns an iterator of no items .
535548
536549
537550.. class :: ResourceLoader
@@ -540,6 +553,10 @@ ABC hierarchy::
540553 :pep: `302 ` protocol for loading arbitrary resources from the storage
541554 back-end.
542555
556+ .. deprecated :: 3.7
557+ This ABC is deprecated in favour of supporting resource loading
558+ through :class: `importlib.abc.ResourceReader `.
559+
543560 .. abstractmethod :: get_data(path)
544561
545562 An abstract method to return the bytes for the data located at *path *.
0 commit comments