Skip to content

bpo-32248: Introduce the concept of Loader.get_resource_reader()#5108

Merged
brettcannon merged 5 commits intopython:masterfrom
brettcannon:tweak_resourcereader
Jan 12, 2018
Merged

bpo-32248: Introduce the concept of Loader.get_resource_reader()#5108
brettcannon merged 5 commits intopython:masterfrom
brettcannon:tweak_resourcereader

Conversation

@brettcannon
Copy link
Copy Markdown
Member

@brettcannon brettcannon commented Jan 5, 2018

For loaders that wish to provide resource reading, they should now implement get_resource_reader(fullname) to return an object compatible with importlib.abc.ResourceReader.

importlib.abc.ResourceLoader has also been documented as deprecated as ResourceReader is more well-defined, full API for similar purposes.

https://bugs.python.org/issue32248

@brettcannon brettcannon added the type-feature A feature request or enhancement label Jan 5, 2018
@brettcannon brettcannon requested a review from warsaw January 5, 2018 23:32
Copy link
Copy Markdown
Member

@warsaw warsaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few minor comments.

Comment thread Doc/library/importlib.rst Outdated
paths should be included in the *resource* argument. This is
because the location of the package that the loader is for acts
as the "directory". Hence the metaphor for directories and file
because the location of the package the reader is for acts as the
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a comma between "is for, acts" so it parses a little easier?

Comment thread Doc/library/importlib.rst
a specific package (instead of potentially representing multiple
packages or a module).

Loaders that wish to support resource reading are expected to
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about:

"... which returns an object implementing this ABC's interface. If the module specified by fullname is not a package, this method should return :const:None" ...?

Comment thread Doc/whatsnew/3.7.rst Outdated
and reading *resources* inside packages. Resources are roughly akin to files
inside of packages, but they needn't be actual files on the physical file
system. Module loaders can implement the
system. Module loaders can support the
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"support" used twice reads a little weird. Maybe the first one can be "provide"?

Comment thread Lib/importlib/abc.py Outdated
"""Abstract base class for loaders to provide resource reading support."""
"""Abstract base class to provide resource-reading support.

Loaders who support resource reading are expected to implement
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/who/that/

@brettcannon brettcannon merged commit bca4218 into python:master Jan 12, 2018
@brettcannon brettcannon deleted the tweak_resourcereader branch January 12, 2018 23:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type-feature A feature request or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants